Webpack issues with css/scss on public folder load

Viewed 163

I need help with my webpack. Currently I have a simple structor but doesn't load the css into the public folderenter image description here

instead loads 2 inline tags.

My Issue is:

the public folder as a index.html with two css with for some reason the get duplicated with my bundle.js.

How do I set a normal css in there? Surely my webpack is wrong.

I'm using react and I have a sass folder with all scss files.

enter image description here

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

module.exports = {
  entry: ["./src/index.js"],
  mode: "development",
  module: {
    rules: [{
        test: /\.s[ac]ss$/i,
        use: [
          // Creates `style` nodes from JS strings
          'style-loader',
          // Translates CSS into CommonJS
          'css-loader',
          // Compiles Sass to CSS
          'sass-loader',
        ],
        sideEffects: true,
      },

      {
        // Images
        test: /\.(png|svg|jpg|gif)$/,
        use: {
          'loader': 'file-loader',
          'options': {
            'name': "[name].[ext]",
            'outputPath': 'assets/images/'
          }
        }
      },
      {
        test: /\.(woff|woff2|eot|ttf|otf)$/i,
        use: {
          loader: 'file-loader',
          options: {
            name: '[name].[ext]',
            outputPath: 'fonts/'
          },
        },
      },
      {
        test: /\.(js|jsx)$/,
        exclude: /(node_modules|bower_components)/,
        loader: "babel-loader",
        options: {
          presets: ["@babel/env"]
        }
      }

    ],
  },
  resolve: {
    extensions: ["*", ".js", ".jsx"]
  },
  output: {
    path: path.resolve(__dirname, "public/"),
    publicPath: "/public/",
    filename: "bundle.js"
  },
  devServer: {
    historyApiFallback: true,
    contentBase: path.join(__dirname, "public/"),
    port: 3000,
    hot: true
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, "src", "pages/index.html")
    })
  ]
};

0 Answers
Related