当我运行脚本dev或prod时,自动前缀会在browserlist-production中从浏览器添加前缀。如何设置环境变量NODE_ENV或BROWSERLIST_ENV?我想在运行“ yarn run dev”时从browserslist-development中添加前缀。
在package.json中
"scripts": {
"dev": "webpack --mode development",
"prod": "webpack --mode production"
},
"browserslist": {
"production": [
"ie >= 8"
],
"development": [
"last 1 chrome version"
]
}
webpack.config.js
var path = require('path');
const ExtractCssChunks = require("extract-css-chunks-webpack-plugin");
const webpack = require("webpack");
module.exports = {
entry: './src/scripts/main.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.css$/,
exclude: /node_modules/,
use:
[
ExtractCssChunks.loader,
{
loader: 'css-loader',
options: {
sourceMap: true,
}
},
{
loader: 'postcss-loader',
options: {
plugins: function() {
return [
require('postcss-import')(),
require('autoprefixer')()
]
}
}
}
]
}
]
},
plugins: [
new ExtractCssChunks({
filename: "bundle.css",
})
]
}