From 00d8fc5ea560c4e99f625f698628e524a3d9290e Mon Sep 17 00:00:00 2001 From: zuiidea Date: Thu, 27 Jul 2017 20:02:20 +0800 Subject: [PATCH] add build:dll --- .roadhogrc.js | 12 +++++++++++- package.json | 3 ++- src/index.html | 1 + webpack.config.js | 30 +++++++++++++++--------------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/.roadhogrc.js b/.roadhogrc.js index e3b62c8..2de5f1e 100644 --- a/.roadhogrc.js +++ b/.roadhogrc.js @@ -36,5 +36,15 @@ export default { ["import", { "libraryName": "antd", "style": true}] ] } - } + }, + "dllPlugin": { + "exclude": [ + "babel-runtime" + ], + "include": [ + "dva/router", + "dva/saga", + "dva/fetch", + ] + } } diff --git a/package.json b/package.json index 6f1e418..c60f0c4 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "scripts": { "dev": "set BROWSER=none&&set HOST=0.0.0.0&&roadhog server", "lint": "eslint --fix --ext .js src", - "build": "roadhog build" + "build": "roadhog build", + "build:dll": "roadhog buildDll" } } diff --git a/src/index.html b/src/index.html index 3615ec3..17b3c93 100644 --- a/src/index.html +++ b/src/index.html @@ -26,6 +26,7 @@ } })() + diff --git a/webpack.config.js b/webpack.config.js index e21dd72..2e2db97 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,21 +1,22 @@ -module.exports = (webpackConfig) => { +module.exports = (webpackConfig, env) => { // FilenameHash // https://webpack.js.org/configuration/output/#output-chunkfilename webpackConfig.output.chunkFilename = '[name].[hash].js' - // ClassnameHash - // webpackConfig.module.rules.map((item) => { - // if (item.use && item.use[0] === 'style') { - // return item.use.map((iitem) => { - // if (iitem && iitem.loader === 'css') { - // iitem.options.localIdentName = '[hash:base64:5]' - // } - // return iitem - // }) - // } - // return item - // }) - + if (env === 'production' && webpackConfig.module) { + // ClassnameHash + webpackConfig.module.rules.map((item) => { + if (item.use && item.use[0] === 'style') { + return item.use.map((iitem) => { + if (iitem && iitem.loader === 'css') { + iitem.options.localIdentName = '[hash:base64:5]' + } + return iitem + }) + } + return item + }) + } // PreLoaders // webpackConfig.module.preLoaders = [{ @@ -24,7 +25,6 @@ module.exports = (webpackConfig) => { // loader: 'eslint', // }] - // Alias webpackConfig.resolve.alias = { components: `${__dirname}/src/components`,