Using webpack-dev-server, I'm able to load ./dist/index.html
at the root path (0.0.0.0:8080
) and to view ./dist/bundle.js
at 0.0.0.0:8080/bundle.js
. I'm getting a 404 when I try to load (0.0.0.0:8080/style.css
).
The CSS in my ./dist
directory is generated by an npm command running node-sass
, not using webpack.
dist/
- index.html
- bundle.js
- style.css
webpack.config.js
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry: "./src/index.ts",
mode: "development",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader, // instead of style-loader
'css-loader'
]
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [
new MiniCssExtractPlugin(
{
filename: './style.css'
//also tried: path.resolve(__dirname, "dist", "style.css")
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "dist", "index.html"),
inject: false
})
],
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
};
(from https://blog.jakoblind.no/css-modules-webpack/)
What should I add or change so that my browser can reach the CSS file at ./dist/style.css
?