From b0502919113d09b184ebbd7072d6e157daaeb4c0 Mon Sep 17 00:00:00 2001 From: zema1 Date: Sun, 26 Nov 2017 16:05:31 +0800 Subject: [PATCH] using `NODE_ENV=development npm run build:dll` to build a dev dll --- README.md | 2 +- build/utils.js | 5 +++++ build/webpack.dll.conf.js | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3c7d13c..4ba4c8e 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Modern browsers and Internet Explorer 10+. ```bash # we use webpack DllReference to decrease the build time, # this command only needs execute once unless you upgrade the package in build/webpack.dll.conf.js -npm run build:dll +NODE_ENV=development npm run build:dll # the dev-server will set proxy table to your backend export TARGET=http://Your-backend diff --git a/build/utils.js b/build/utils.js index 0ad49ba..3e6009b 100644 --- a/build/utils.js +++ b/build/utils.js @@ -70,3 +70,8 @@ exports.styleLoaders = function (options) { } return output } + +exports.getNodeEnv = function () { + const NODE_ENV = process.env.NODE_ENV + return NODE_ENV ? NODE_ENV: 'production' +} diff --git a/build/webpack.dll.conf.js b/build/webpack.dll.conf.js index a16547b..f514319 100644 --- a/build/webpack.dll.conf.js +++ b/build/webpack.dll.conf.js @@ -2,6 +2,9 @@ const webpack = require('webpack'); const path = require('path'); const UglifyJSPlugin = require('uglifyjs-webpack-plugin') const config = require('../config') +const utils = require('./utils') + +const NODE_ENV = utils.getNodeEnv() const vendors = [ 'vue/dist/vue.esm.js', @@ -25,7 +28,7 @@ module.exports = { }, plugins: [ new webpack.DefinePlugin({ - 'process.env': config.build.env + 'process.env': NODE_ENV === 'production' ? config.build.env : config.dev.env }), new webpack.optimize.ModuleConcatenationPlugin(), new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /zh-cn/),