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?
html-webpack-plugin
bundle.js
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 }])
Questions and answers: 1. Generate vendor.js to /dll/, 2. template.html uses the template syntax of html-webpack-plugin
vendor.js
/dll/
<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
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
Questions and answers:
1. Generate
vendor.js
to/dll/
,2. template.html uses the template syntax of html-webpack-plugin
3. Set webpack.dev.config.js
Only for development environment