Skip to content

Instantly share code, notes, and snippets.

@jwchang0206
Created December 3, 2020 11:48
Show Gist options
  • Save jwchang0206/6e6cbc8f28b53ca4a966bc8cc597350c to your computer and use it in GitHub Desktop.
Save jwchang0206/6e6cbc8f28b53ca4a966bc8cc597350c to your computer and use it in GitHub Desktop.
Craco config for TypeScript with eslint-loader error fix
const CracoSwcPlugin = require('craco-swc');
module.exports = {
plugins: [
{
plugin: {
...CracoSwcPlugin,
overrideCracoConfig: ({ cracoConfig }) => {
if (typeof cracoConfig.eslint.enable !== 'undefined') {
cracoConfig.disableEslint = !cracoConfig.eslint.enable;
}
delete cracoConfig.eslint;
return cracoConfig;
},
overrideWebpackConfig: ({ webpackConfig, cracoConfig }) => {
if (
typeof cracoConfig.disableEslint !== 'undefined' &&
cracoConfig.disableEslint === true
) {
webpackConfig.plugins = webpackConfig.plugins.filter(
(instance) => instance.constructor.name !== 'ESLintWebpackPlugin',
);
}
return webpackConfig;
},
},
options: {
swcLoaderOptions: {
jsc: {
externalHelpers: true,
target: 'es5',
parser: {
syntax: 'typescript',
tsx: true,
dynamicImport: true,
exportDefaultFrom: true,
},
},
},
},
},
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment