I have a project with CRA 5 and I needed to add some aliases so I had to install craco but I have a problem, when I run my tests with cypress I get this error:
Error: Webpack Compilation Error
./src/components/Common/Inputs/Checkbox/scss/checkbox.scss 1:0
Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> @import '../../../../../scss/main.scss';
I have tried many ways, also overriding the sass loader:
const path = require('path');
const sassRegex = /\.(scss)$/;
const sassModuleRegex = /\.module\.(scss|sass)$/;
module.exports = {
webpack: {
extensions: ['ts', 'tsx', 'js', 'jsx'],
alias: {
'@layout': path.resolve(__dirname, 'src/components/Layout'),
'@components': path.resolve(__dirname, 'src/components'),
'@contexts': path.resolve(__dirname, 'src/contexts'),
'@hooks': path.resolve(__dirname, 'src/hooks'),
'@lib': path.resolve(__dirname, 'src/lib'),
'@pages': path.resolve(__dirname, 'src/pages'),
'@styles': path.resolve(__dirname, 'src/scss'),
'@common': path.resolve(__dirname, 'src/components/Common'),
'@icons': path.resolve(__dirname, 'src/components/Common/Icons'),
'@inputs': path.resolve(__dirname, 'src/components/Common/Inputs'),
'@assets': path.resolve(__dirname, 'src/assets'),
},
configure: (webpackConfig, { env, paths }) => {
const overrideSassLoaderConfiguration = {
test: sassRegex,
exclude: sassModuleRegex,
include: [path.resolve(__dirname, 'src', 'sass')],
use: ['style-loader', 'css-loader', 'sass-loader'],
};
webpackConfig.module.rules = [...webpackConfig.module.rules, overrideSassLoaderConfiguration];
return webpackConfig;
},
},
};
but nothing seems to work, what am I doing wrong?...