详解基于webpack2.x的vue2.x的多页面站点(3)

{ 'pages/boys/index': './src/pages/boys/index.js', 'pages/goods/index': './src/pages/goods/index.js', 'pages/index/index': './src/pages/index/index.js', 'pages/sotho/index': './src/pages/sotho/index.js' }

与我们想要的行为一致

同样我们也升级下我们的webpack.dev.conf.js中的plugins

var htmls = glob.sync('./src/pages/**/*.html').map(function (item) { return new HtmlWebpackPlugin({ filename: './' + item.slice(6), template: item, inject: true, chunks:[item.slice(2, -5)] }); }); module.exports = merge(baseWebpackConfig, { module: { rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap }) }, // cheap-module-eval-source-map is faster for development devtool: '#cheap-module-eval-source-map', plugins: [ new webpack.DefinePlugin({ 'process.env': config.dev.env }), // https://github.com/glenjamin/webpack-hot-middleware#installation--usage new webpack.HotModuleReplacementPlugin(), new webpack.NoEmitOnErrorsPlugin(), // https://github.com/ampedandwired/html-webpack-plugin new FriendlyErrorsPlugin() ].concat(htmls) })

生成的是:

HtmlWebpackPlugin { options: { template: './src/pages/boys/index.html', filename: './pages/boys/index.html', hash: false, inject: true, compile: true, favicon: false, minify: false, cache: true, showErrors: true, chunks: [ 'pages/boys/index' ], excludeChunks: [], title: 'Webpack App', xhtml: false } }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wydywg.html