2

I have the webpack.config.js like the following

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

Whenever I run a prod build using

webpack -p

it inserts a script tag

<script type="text/javascript" src="/bundle.js"></script>

into my index.html I could not figure out which part of the webpack.config.js is doing this... How can I stop this?

thanks

mark

2 Answers 2

4

The plugin in charge of doing that is HTMLWebpackPlugin which if you pass the option inject as false, then it will stop injecting your assets to the HTML.

Here you have the full doc https://github.com/jantimon/html-webpack-plugin

Hope it helps.

Sign up to request clarification or add additional context in comments.

1 Comment

Cool! it work even though it still touch the index.html but no change.
0

Old

plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(),
    new HtmlWebpackPlugin({ template: './index.html' })
]

New

plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
  ]

Then you have to reference those bundles that webpack generates yourself inside your index.html file

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.