Closed abenhamdine closed 5 years ago
Ok my bad, it was due to an absolute import in one of my files :
import '/resources/main.less'
which was handled by config-override but not by my craco config with these lines :
const path = require('path')
config.resolve.modules = [path.resolve('src')].concat(config.resolve.modules)
If I modify it to a relative import it works.
Hi, sorry you ran into that issue! Here's how you can do the same thing with craco
:
const CracoAntDesignPlugin = require('craco-antd');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const WebpackBar = require('webpackbar');
const path = require('path');
module.exports = {
webpack: {
plugins: [new BundleAnalyzerPlugin(), new WebpackBar({ profile: true })],
configure: config => {
config.resolve.modules = [path.resolve('src')].concat(config.resolve.modules);
return config;
},
},
plugins: [{ plugin: CracoAntDesignPlugin }],
};
I just tried that out and it sets up the same resolve.modules
in your webpack config. Hope that helps!
Also I just realized that you can continue using react-app-rewire-ts-jest, because it only operates on the webpack config object. So here's your complete config, rewritten for craco:
const CracoAntDesignPlugin = require('craco-antd');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const WebpackBar = require('webpackbar');
const rewireTsJest = require('react-app-rewire-ts-jest');
const path = require('path');
module.exports = {
webpack: {
plugins: [new BundleAnalyzerPlugin(), new WebpackBar({ profile: true })],
configure: config => {
config.resolve.modules = [path.resolve('src')].concat(config.resolve.modules);
return config;
},
},
jest: {
configure: config => {
// placeholder
const configTsJest = {};
config = rewireTsJest(config, configTsJest);
return {
...config,
reporters: [
'default',
[
'./node_modules/jest-html-reporter',
{
pageTitle: 'Payroll-app-next: Tests suite',
outputPath: 'tests/report/index.html',
includeFailureMsg: true,
dateFormat: 'dd/mm/yyyy HH:MM',
sort: 'status',
},
],
],
collectCoverage: true,
collectCoverageFrom: ['src/**/*.{ts,tsx}'],
coveragePathIgnorePatterns: ['src/state/state.d.ts'],
coverageReporters: ['html', 'json'],
};
},
},
plugins: [{ plugin: CracoAntDesignPlugin }],
};
I haven't tested the jest part, but let me know if that works!
Hello,
Thx for this plugin. Unfortunately, I didn't manage to make it work with typscript.
Here is my craco config :
If I run
yarn run start
:My previous config with react-app-rewired was :
Have you any idea to resolve this issue ?