如何防止Webpack为CSS创建JS文件

如何防止Webpack为CSS创建JS文件

本文介绍了如何防止Webpack为CSS创建JS文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

const path = require('path');

var webpack = require('webpack'),
    ExtractTextPlugin = require("extract-text-webpack-plugin");
var nodeExternals = require('webpack-node-externals');
const CssEntryPlugin = require("css-entry-webpack-plugin");

module.exports = {
    entry: {
        index: './js/index.js',
        product_details: './js/index.js',
        signup: ['./js/signup.js','./js/index.js'],
        signup_style: ['./css/signup.css']
   },
    output: {
        path: path.resolve(__dirname, 'dist/js'),
        filename: "[name].min.js"
    },
    externals: [nodeExternals()],
    module: {
        rules: [
          {
            test: /\.js/,
            use: 'babel-loader',
            exclude: /node_modules/,
          },
          {
            test: /\.css$/,
            use: ExtractTextPlugin.extract({
                fallback: 'style-loader',
                use: [{
                        loader: 'css-loader',
                        options: {
                            minimize: true,
                        }
                    }]
            })
          }
        ]
      },
      plugins: [
        new ExtractTextPlugin('../css/[name].css')
      ]
};

上面是我的webpack.config.js文件。它会创建 signup_style.min.js signup_style.css 文件。我只想创建
signup_style.css 文件,而不想要 signup_style.min.js

Above is my webpack.config.js file. It creates signup_style.min.js and signup_style.css files. I want only signup_style.css file tocreate and not signup_style.min.js.

我们该怎么做?

推荐答案

您可以使用

这篇关于如何防止Webpack为CSS创建JS文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 08:15