Skip to content

when the env is production,it generated css file is empty,but in development is right #122

Closed
@dongqizhen

Description

@dongqizhen

this is my config in config.js

const devMode = process.env.NODE_ENV !== 'production'

in optimization:

splitChunks: {

        cacheGroups: {
            styles: {
              name: 'styles',
              test: /\.scss|css|sass$/,
              chunks: 'all',
              enforce: true
            }
        }
    },

in rules:
{
test: /.(sass|scss)$/,
use:
[
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
'sass-loader',
],
}

in plugin:
new MiniCssExtractPlugin({
filename: devMode ? 'css/[name].css' : 'css/[name].[hash].css',
chunkFilename: devMode ? 'css/[id].css' : 'css/[id].[hash].css',
})

the env is production that view :
7twx5zuw99 ibeo7tod79w

but in development :
c4vky vqejzuc3 5 2 _pe

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions