Can I use webpack to generate CSS and JS separately?

后端 未结 7 2024
长情又很酷
长情又很酷 2020-12-02 07:37

I have:

  1. JS files that I want to bundle.
  2. LESS files that I want to compile down to CSS (resolving @imports into a single bundle).

I was

7条回答
  •  忘掉有多难
    2020-12-02 08:25

    Like others mentioned you can use a plugin.

    ExtractTextPlugin is deprecated.

    You can use the currently recommended MiniCssExtractPlugin in your webpack configuration:

    module.exports = {
         entry: {
            home: ['index.js', 'index.less']
         },
         plugins: [
                new MiniCssExtractPlugin({
                    filename: '[name].css',
                }),
         ]
    }
    

提交回复
热议问题