Using html-webpack-plugin
can only write the application's bundle.js
to html, but not the vendor generated by the dll. Is there any way?
扔个三星炸死你2017-07-05 10:54:50
You can use add-asset-html-webpack-plugin to add the packaged files to html.
Quote in the following way, or refer to my vue-2.0template
If you like it, you can give it a star
new HtmlWebpackPlugin({
filename: itemPath,
template: template,
inject: true,
title: item.title || 'Document',
chunks: chunks,
chunksSortMode: 'dependency',
}),
new AddAssetHtmlPlugin([{
filepath: path.resolve(__dirname, config.build.dll.basePath, config.build.dll.fileName),
outputPath: utils.assetsPath('common/js/'),
publicPath: path.join(config.build.publicPath, 'common/js'),
includeSourcemap: true
}])
女神的闺蜜爱上我2017-07-05 10:54:50
Questions and answers:
1. Generate vendor.js
to /dll/
,
2. template.html uses the template syntax of html-webpack-plugin
<body>
<script src="<%= htmlWebpackPlugin.optiions.vendor %>"></script>
</body>
3. Set webpack.dev.config.js
//...
plugins:[
new HTMLPlugin({
template: './src/template.html',
filename: 'index.html'
vendor: '/dll/' + manifest.name + '.js/' //manifest就是dll生成的json
})
]
Only for development environment