需求:开发模式下打印语句生效,生产模式下打印语句失效
使用Webpack内置的DefinePlugin插件
const webpack = require('webpack')
module.exports = {
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV':JSON.stringify(process.env.NODE_ENV)
})
]
}





需求:开发模式下打印语句生效,生产模式下打印语句失效
使用Webpack内置的DefinePlugin插件
const webpack = require('webpack')
module.exports = {
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV':JSON.stringify(process.env.NODE_ENV)
})
]
}