从零开始webpack4.x(十)区分不同环境

webpack区分不同环境

--创建不同环境的配置文件 使用webpack-merge 合并webpack不同环境配置文件

    通过npx webpack --config 相应环境配置文件 打包 或者配置package.json中的 scripts

webpack.dev.js

// webpack-merge 合并webpack 不同环境配置文件
let { smart } = require('webpack-merge');
let base = require('./webpack.base');

module.exports = smart(base, {
    mode: 'development'
    其他配置
    .... 
})

webpack.prod.js

let { smart } = require('webpack-merge');
let base = require('./webpack.base');

module.exports = smart(base, {
    mode: 'production',
    entry: {},
    output: {},
    devServer: {},
    module: {},
    plugins: [], 
})
原文地址:https://www.cnblogs.com/aisiqi-love/p/12686202.html