3

A simple webpack configuration but not working :

var path = require("path");
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  module: {
    rules: [
      {
        test:/\.css$/,
        use:['style-loader','css-loader']
      }
    ]
  },
    plugins: [
    new HtmlWebpackPlugin({
        hash: true,
        filename: 'index.html',
        title: 'My Awesome application',
        myPageHeader: 'Hello World',
        template: './src/index.html',
      })
    ],
    devServer: {
      port: 8000,
      hot: true
    },

};

When I run with "hot : false" it works, my CSS is loaded, but with "hot: true" I can see my html but the style is not loaded...

"webpack": "^4.16.0",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4"

If I build with webpack and then open dist/index.html in my browser, it works too.

In index.js I imported my css like that :

import './styles/app.css';

~

freezix
  • 83
  • 4

1 Answers1

3

I removed hot: true and added --hot option to my script, the command line version auto add a plugin.

freezix
  • 83
  • 4