我有webpack.config.js,如下所示
var path = require('path')
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var PORT = process.env.PORT || 3333
var PRODUCTION = process.env.NODE_ENV === 'production'
var SRC_DIR = path.resolve(__dirname, './src')
var Webpack_isomorphic_tools_plugin = require('webpack-isomorphic-tools/plugin')
var config = {
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, '/'),
filename: 'bundle.js',
publicPath: '/'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new HtmlWebpackPlugin({ template: './index.html' })
],
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [
{
test: /\.jsx?$/,
loaders: ['react-hot', 'babel'],
include: SRC_DIR
},{ test: /\.css$/, loader: "style-loader!css-loader" }
]
}
}
if (!PRODUCTION) {
config.devtool = 'eval'
}
module.exports = config
每当我使用
运行prod构建时webpack -p
它会插入一个脚本标记
<script type="text/javascript" src="/bundle.js"></script>
进入我的index.html 我无法弄清楚webpack.config.js的哪个部分正在执行此操作... 我怎么能阻止这个?
感谢
标记
答案 0 :(得分:1)
负责执行此操作的插件为HTMLWebpackPlugin
,如果您将选项inject
作为false
传递,则会停止将您的资源注入HTML。
您可以在此处获得完整的文档https://github.com/jantimon/html-webpack-plugin
希望它有所帮助。
答案 1 :(得分:0)
旧
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new HtmlWebpackPlugin({ template: './index.html' })
]
新
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]
然后你必须引用webpack在index.html文件中生成你自己的捆绑包