Webpack 原始配置编写

// webpack.config.js
const easywebpack = require('easywebpack-vue');
const webpack = easywebpack.webpack;
const merge = easywebpack.merge;
const env = process.env.BUILD_ENV;
const baseWebpackConfig = easywebpack.getWebpackConfig({
    env, // 根据环境变量生成对应配置,可以在 npm script 里面配置,支持dev, test, prod 模式
    target : 'web', // target: web 表示只获取前端构建 Webpack 配置
    entry:{
        app: 'src/index.js'
    }
});

// 拿到基础配置, 可以进行二次加工
const webpackConfig = merge(baseWebpackConfig, { 
  // 自定义配置
})

module.exports = webpackConfig;

使用 webpack-cli 构建: webpack --config webpack.config.js

easywebpack-cli 模式配置编写

// webpack.config.js
module.exports = {
  framework: 'vue', //  表示使用 easywebpack-vue 方案构建
  target : 'web', // target: web 表示只获取前端构建 Webpack 配置
  entry:{
    app: 'src/index.js'
  }
}

使用 easywebpack-cli 构建:easy build dev easy build test easy build prod


Author: sky
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source sky !
 Previous
版本历史 版本历史
easywebpack 版本发布说明
2020-04-18 sky
Next 
单页面举例 单页面举例
easywebpack-vue 构建单页面应用Vue + Vuex + Vue-Router 基本实现router/index.js 实现// router/index.js import Vue from 'vue'; import VueRouter from 'vue-router'; import ListView from './list'; import DetailView from './detail...
2020-04-18 sky