arackaf / customize-cra

Override webpack configurations for create-react-app 2.0
MIT License
2.77k stars 270 forks source link

Is there a way to disable MiniCssExtractPlugin? #196

Open Bert0324 opened 4 years ago

Bert0324 commented 4 years ago

As the title says, I want to disable MiniCssExtractPlugin in CRA, coz I want my final bundle without CSS file, all styles are included in JS.

Is there a possible way to do it by changing configuration?

Many Thanks Dudes.

evertbouw commented 4 years ago

Drop this within override():

config => {
  config.plugins = config.plugins.filter(plugin => plugin.constructor.name !== "MiniCssExtractPlugin");
  return config;
},
gogones commented 3 years ago

Drop this within override():

config => {
  config.plugins = config.plugins.filter(plugin => plugin.constructor.name !== "MiniCssExtractPlugin");
  return config;
},

i got this error when i build with plugin.constructor.name !== 'MiniCssExtractPlugin'

Screen Shot 2020-10-21 at 17 03 08
evertbouw commented 3 years ago

Filtering out the plugin no longer works. I don't know a way around it

Xooone47 commented 3 years ago

you can replace the mini-css-extract-plugin with style-loader.

const {override, adjustStyleLoaders} = require('customize-cra');

override(
    adjustStyleLoaders(({use}) => {
        const styleLoader = use[0].loader.replace('mini-css-extract-plugin/dist/loader.js', 'style-loader/index.js');
        use[0] = styleLoader;
    })
);