Skip to content

Instantly share code, notes, and snippets.

@Timer
Created March 29, 2020 05:12
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Timer/2ed585ff0db6b885a7f7dd738a982b13 to your computer and use it in GitHub Desktop.
Save Timer/2ed585ff0db6b885a7f7dd738a982b13 to your computer and use it in GitHub Desktop.
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const withTM = require("next-transpile-modules")([
// `monaco-editor` isn't published to npm correctly: it includes both CSS
// imports and non-Node friendly syntax, so it needs to be compiled.
"monaco-editor"
]);
module.exports = withTM({
webpack(config) {
const rule = config.module.rules
.find(rule => rule.oneOf)
.oneOf.find(
r =>
// Find the global CSS loader
r.issuer && r.issuer.include && r.issuer.include.includes("_app")
);
if (rule) {
rule.issuer.include = [
rule.issuer.include,
// Allow `monaco-editor` to import global CSS:
/[\\/]node_modules[\\/]monaco-editor[\\/]/
];
}
config.plugins.push(new MonacoWebpackPlugin({ languages: ["javascript"] }));
return config;
}
});
@benebsiny
Copy link

After modified the code like above, the module.css file don't work anymore, how can I make module.css work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment