D
D
DeniSidorenko2020-10-08 07:44:23
webpack
DeniSidorenko, 2020-10-08 07:44:23

Why does webpack create 0. junk files?

Hello, here is the webpack code

const path = require('path');
const { CleanWebpackPlugin } =  require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin')


const cssLoaders = [
  {
    loader: MiniCssExtractPlugin.loader,

  },
  {loader: 'css-loader'},
  {loader: 'postcss-loader'},
  {loader: 'stylus-loader'}
]

module.exports = {
    context: path.resolve(__dirname, 'src'),
    entry: './index.js',
    mode: 'development',
    output: {
        filename: "main.[hash].js",
        path: path.resolve(__dirname, 'dist/')
    },
  resolve: {
    extensions: ['.js'],
    alias: {
      '@': path.resolve(__dirname, 'src'),
      '@core': path.resolve(__dirname, 'src/core')
    }
  },
  plugins: [
      new CleanWebpackPlugin(),
      new HtmlWebpackPlugin({
          template: "index.html"
      }),
      new CopyPlugin({
        patterns: [
          {
            from: './favicon.ico',
            to: path.resolve(__dirname, 'dist/')
          },
        ]
      }),
      new MiniCssExtractPlugin({
        filename: 'test.css',
      })
    ],
    module: {
      rules: [
        {
          test: /\.styl(us)?$/,
          use: cssLoaders
        },
      ],
    }
}


It creates 0.main.0244f427446a0099ebfb.js and 0.test.css in the dist folder.
It also creates the necessary files such as js.
The problem is that 0.main.0244f427446a0099ebfb.js is not required at all
and 0.test.css compiles correctly but is not automatically imported into html

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question