Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
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>你好啊</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 14 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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.