diff --git a/template/client/app/router/routerConfig.js b/template/client/app/router/routerConfig.js index 21e8f7f..28cdf2a 100644 --- a/template/client/app/router/routerConfig.js +++ b/template/client/app/router/routerConfig.js @@ -4,7 +4,7 @@ export default [ name:'start', url:"/start", template:'', - lazyload:require("bundle?lazy&name=start!../components/start/start.js"), + lazyload:require("bundle-loader?lazy&name=start!../components/start/start.js"), tracking:{ key:'start' } diff --git a/template/client/index.html b/template/client/index.ejs similarity index 92% rename from template/client/index.html rename to template/client/index.ejs index c6fa67c..dc0a494 100755 --- a/template/client/index.html +++ b/template/client/index.ejs @@ -12,6 +12,7 @@ + <%= htmlWebpackPlugin.files.webpackManifest %> diff --git a/template/package.json b/template/package.json index a3db551..a49a753 100644 --- a/template/package.json +++ b/template/package.json @@ -21,6 +21,7 @@ "bundle-loader": "^0.5.4", "browser-sync": "^2.11.1", "chai": "^3.4.0", + "chunk-manifest-webpack-plugin": "^1.1.0", "connect-history-api-fallback": "^1.1.0", "css-loader": "^0.19.0", "file-loader": "^0.8.5", @@ -29,7 +30,7 @@ "gulp-rename": "^1.2.2", "gulp-template": "^3.0.0", "gulp-util": "^3.0.7", - "html-webpack-plugin": "^1.7.0", + "html-webpack-plugin": "^2.28.0", "karma": "^0.13.9", "karma-chai": "^0.1.0", "karma-chrome-launcher": "^0.2.0", @@ -46,7 +47,7 @@ "run-sequence": "^1.1.0", "style-loader": "^0.12.2", "supports-color": "^3.1.2", - "webpack": "^1.9.5", + "webpack": "^2.6.1", "webpack-dev-middleware": "^1.4.0", "webpack-hot-middleware": "^2.6.0", "webpack-dev-server": "^1.15.1", @@ -54,6 +55,8 @@ "is-utf8": "^0.2.0", "http-proxy-middleware": "^0.13.0", "happypack": "^4.0.0-beta.1", + "webpack-manifest-plugin": "^1.1.0", + "webpack-md5-hash": "^0.0.5", "webpack-parallel-uglify-plugin": "^0.4.1" }, "scripts": { diff --git a/template/webpack.config.js b/template/webpack.config.js index d9ce3cc..d8988ff 100755 --- a/template/webpack.config.js +++ b/template/webpack.config.js @@ -92,12 +92,12 @@ module.exports = { new HappyPack({ id: 'img', threads: os.cpus().length, - loaders: ['file?name=assets/img/img-[hash].[ext]'] + loaders: ['file-loader?name=assets/img/img-[chunkhash].[ext]'] }), new HappyPack({ id: 'html', threads: os.cpus().length, - loaders: ['raw'] + loaders: ['raw-loader'] }), new HappyPack({ id: 'font', @@ -108,7 +108,7 @@ module.exports = { // It also adds hash to all injected assets so we don't have problems // with cache purging during deployment. new HtmlWebpackPlugin({ - template: 'client/index.html', + template: 'client/index.ejs', inject: 'body', hash: true }), @@ -119,7 +119,7 @@ module.exports = { }), new webpack.optimize.CommonsChunkPlugin({ - name: 'vendor', + name: ['vendor','manifest'], minChunks: function (module, count) { return module.resource && module.resource.indexOf(path.resolve(__dirname, 'client')) === -1; } diff --git a/template/webpack.dist.config.js b/template/webpack.dist.config.js index d5ca528..07eaecb 100755 --- a/template/webpack.dist.config.js +++ b/template/webpack.dist.config.js @@ -5,12 +5,15 @@ var customConfig = require('./custom.env.config'); var os = require('os'); var ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin'); +var ManifestPlugin = require('webpack-manifest-plugin'); +var ChunkManifestPlugin = require('chunk-manifest-webpack-plugin'); +var WebpackMd5Hash = require('webpack-md5-hash'); var distPath = customConfig.distPath; config.output = { - filename: '[name].bundle.js', - chunkFilename:'[name].min.js', + filename: '[name].[chunkhash].bundle.js', + chunkFilename:'[name].[chunkhash].min.js', publicPath: '', path: distPath }; @@ -41,6 +44,14 @@ config.plugins = config.plugins.concat([ 'NODE_ENV': JSON.stringify('sit'), 'DEBUG': false } + }), + //引入manifest + new WebpackMd5Hash(), + new ManifestPlugin(), + new ChunkManifestPlugin({ + filename: "chunk-manifest.json", + manifestVariable: "webpackManifest", + inlineManifest: true }) ]);