webpackextract-text-plugin

Link css filename with hash to index.html after the Extract Text Plugin


I would like to ask how can I link the generated css files with a hash name to my index.html after I run the npm for my production:

"build-production": "webpack -p --progress --colors --config webpack.config.production.js"

This is the plugin in my webpack config that will generate the filename with hash since every time I build for production it generates a new hash filename. Is there a way that can automatically do it without manually editting the index.html?

plugins: [
    new ExtractTextPlugin("css/[name][contenthash].css")
]

Solution

  • html-webpack-plugin is the answer.

    It can automatically add link and script tag to index.html for generated css and js file.