@ufly/wpk-cfg
v0.7.26
Published
webpack5 config core
Downloads
1
Readme
wpk-cfg
webpack config
Usage
const { entry, mainChain, devChain } = require('@ufly/wpk-cfg');
const isProduction = process.env.NODE_ENV == 'production';
if (isProduction) {
const publicPath = '/dist/';
mainChain
.output
.publicPath(publicPath)
.end()
} else {
const cert = {
//...
};
devChain.devServer.https(cert);
}
const webpackChain = isProduction ? mainChain : devChain;
const config = webpackChain.toConfig();
module.exports = config;
支持的环境变量
COMPILE=swc|babel
:指定编译器swc
【默认值】,使用swc-loader
babel
,使用babel-loader
CSS_MINIMIZER=esbuild|css
:指定 CSS minimizeresbuild
【默认值】,使用ESBuildMinifyPlugin
css
,使用css-minimizer-webpack-plugin
示例如下:
{
"scripts": {
"dev": "webpack serve",
"build": "cross-env NODE_ENV=production webpack --mode=production",
"dev": "cross-env CSS_MINIMIZER=css COMPILE=babel webpack serve",
"build": "cross-env NODE_ENV=production CSS_MINIMIZER=css COMPILE=babel webpack --mode=production",
}
}