- Configured webpack to use contentHash in bundle file name - This caused a problem with out script tag in index.html - We installed HtmlWebpackPlugin to help us generate a new index.html - It automatically includes the correct script tag at the bottom - We created a template file that we passed in called template.html - We deleted the original index.html because we don't need it anymore - Make sure you are opening dist/index.html now to view the app
29 lines
605 B
JavaScript
29 lines
605 B
JavaScript
const path = require("path");
|
|
var HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
|
|
module.exports = {
|
|
mode: "development",
|
|
entry: "./src/index.js",
|
|
output: {
|
|
filename: "main.[contentHash].js",
|
|
path: path.resolve(__dirname, "dist")
|
|
},
|
|
plugins: [
|
|
new HtmlWebpackPlugin({
|
|
template: "./src/template.html"
|
|
})
|
|
],
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.scss$/,
|
|
use: [
|
|
"style-loader", //3. Inject styles into DOM
|
|
"css-loader", //2. Turns css into commonjs
|
|
"sass-loader" //1. Turns sass into css
|
|
]
|
|
}
|
|
]
|
|
}
|
|
};
|