Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
envatt-webpack-loader
Advanced tools
npm install envatt-webpack-loader -D
const areaName = process.env.VUE_APP_AREA || 'XXX'
...
chainWebpack: config => {
config.module
.rule('app-env')
.test(/.(vue|js)$/)
.pre() // 重要,一定要在最开始调用
.include
.add(resolve(__dirname, 'src'))
.end()
.use('app-env')
.loader('envatt-webpack-loader')
.options({areaName: areaName}) // 传入环境变量
.end()
}
...
创建.env.[mode]文件,例如:.env.A
VUE_APP_AREA=这是A环境
.env.B
VUE_APP_AREA=这是B环境
package.json配置:
"serve:A": "vue-cli-service serve --mode A",
"serve:B": "vue-cli-service serve --mode B",
<template>
<div class="home">
<!-- 这个代码不会被条件注释识别 -->
<h1>这个代码不会被条件注释识别</h1>
<!-- #ifdef 这是A环境 -->
<h1>这是A环境的代码</h1>
<!-- #endif -->
<!-- #ifdef 这是B环境 -->
<h1>这是B环境的代码</h1>
<!-- #endif -->
<p>Hello</p>
<button @click="handleAlert">Click Me</button>
</div>
</template>
<script>
export default {
name: 'HomeView',
components: {
HelloWorld
},
methods: {
handleAlert() {
// #ifdef 这是A环境
alert('这是A环境的代码')
// #endif
// #ifdef 这是B环境
alert('这是B环境的代码')
// #endif
}
}
}
</script>
FAQs
一个通过代码注释,区分环境的webpack-loader
The npm package envatt-webpack-loader receives a total of 1 weekly downloads. As such, envatt-webpack-loader popularity was classified as not popular.
We found that envatt-webpack-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.