html.js
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <scritp><%= compilation.assets[htmlWebpackPlugin.files.chunks.main.entry.substr(htmlWebpackPlugin.files.publicPath.length)].source() %></scritp> </body> </html>
webpack.config.js
var htmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { // 入口文件 entry: { a: './a.js', main: './main.js' }, // 出口文件 output: { filename: 'js/[name].js', path: './dist' }, // 插件安装 plugins: [ new htmlWebpackPlugin({ filename: 'a.html', template: './index.html', inject: 'body', excludeChunks: ['main'] }) ] };
问题:
<scritp><%= compilation.assets[htmlWebpackPlugin.files.chunks.main.entry.substr(htmlWebpackPlugin.files.publicPath.length)].source() %></scritp>的方式加载的脚本能不能excludeChunks
掉?
接口里用main.entry写的方法,在webpack.config文件中的excludeChunks里就不能把‘main’排除掉
可以的
have a try