jaredpalmer / razzle

✨ Create server-rendered universal JavaScript applications with no configuration
https://razzlejs.org
MIT License
11.1k stars 868 forks source link

How to use 'mini-css-extract-plugin' in razzle config #1931

Open AnshuBansal6 opened 3 months ago

AnshuBansal6 commented 3 months ago

I am getting this error -

Could not find a declaration file for module 'mini-css-extract-plugin'. '/..t/node_modules/mini-css-extract-plugin/dist/cjs.js' implicitly has an 'any' type. Try npm i --save-dev @types/mini-css-extract-plugin if it exists or add a new declaration (.d.ts) file containing declare module 'mini-css-extract-plugin';

dmitryshelomanov commented 3 months ago

mini-css-extract-plugin in razzle by default

But if you want to customize it

const MiniCssExtractPlugin = require('mini-css-extract-plugin');

function patchMiniCssExtractorOptions({ plugins }) {
  const plugin = plugins.find(plugin => plugin instanceof MiniCssExtractPlugin);

  if (plugin) {
    plugin.options.ignoreOrder = true;
  }
}

Pass it to modifyWebpackConfig