@blueking/webpack5-cli-service

// 生产环境 bk-webpack5-service build

Usage no npm install needed!

<script type="module">
  import bluekingWebpack5CliService from 'https://cdn.skypack.dev/@blueking/webpack5-cli-service';
</script>

README

bk-webpack5-service

使用

// 生产环境
bk-webpack5-service build

// 开发环境
bk-webpack5-service dev

自定义配置

项目根目录创建 bk.config.js,支持两个类型配置

提供一个函数

module.exports = function (config, option) {

}

提供一个Object

module.exports = {
    entry: {
        ...
    },
    output: {
        ...
    }
}

环境变量

process.env.NODE_ENV = 'development' / 'production'

如何设置环境变量

根目录创建 bk.config.js

const webpack = require('webpack')

module.exports = function (config, option) {
  return {
    ...config,
    plugins: [
      ...config.plugins,
      new webpack.DefinePlugin({
        TEST_ENV: option.production ? JSON.stringify('prodution') : JSON.stringify('development')
      })
    ]
  }
}