Я пытаюсь создать несколько HTML, которые все используют один файл CSS и JS. Я успешно загрузил оба html-файла, но при полной перезагрузке (shift + cmd + r) в других html-файлах, кроме index.html, получается Cannot GET /
my webpack.config.js
:1005 *
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
const path = require("path");
module.exports = {
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.html$/,
use: [
{
loader: "html-loader",
options: { minimize: true }
}
]
},
{
test: /\.(png|svg|jpg|gif)$/,
use: ['file-loader']
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader"
]
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader"
]
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'static/fonts/',
publicPath: '../fonts/'
}
}
]
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html",
filename: "./index.html",
chunks: ["index"],
inject: true
}),
new HtmlWebpackPlugin({
template: "./src/otherPage.html",
filename: "./otherPage.html",
chunks: ["index"],
inject: true
}),
new MiniCssExtractPlugin({
filename: "static/css/style.css",
chunkFilename: "style.css"
}),
new WorkboxPlugin.GenerateSW({
clientsClaim: true,
skipWaiting: true,
runtimeCaching: [{
// Match any request that ends with .png, .jpg, .jpeg or .svg.
urlPattern: /\.(?:png|jpg|jpeg|svg)$/,
// Apply a cache-first strategy.
handler: 'CacheFirst',
options: {
// Use a custom cache name.
cacheName: 'images',
},
}],
})
],
entry: {
"index": "./src/index.js",
// "gobox": "./src/index.js"
},
output: {
publicPath: "/",
path: path.resolve(__dirname, "dist"),
filename: "static/js/[name].js",
chunkFilename: "static/js/[id].js"
},
devServer: {
open: 'Google Chrome',
historyApiFallback: false,
contentBase: path.resolve(__dirname, "dist"),
}
}
Забавно, если я только делаю обычное обновление (cmd + r) в браузере, файл загружается обратно, я предполагаю, что это из кэша браузера.
Ячего-то не хватает? Заранее благодарим за руководство.