Closed dominikspiertz closed 2 years ago
It seems to be related to the @nrwl/web
. We are experiencing a similair issue. Leaving it on 12.x
and our builds compile fine. We do not use less
but sass
instead.
I am also getting this using sass and nx@13.8.3
Ok so I found a weird solution to this (after a veeeery long time). The error was being thrown by a single module.scss
file that was located in the shared assets of my repo. Eventually by deleting all the comments in the file I got it to work? So I guess the issue was related to the post-css
stage in the webpack rules?
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏
Ok so I found a weird solution to this (after a veeeery long time). The error was being thrown by a single
module.scss
file that was located in the shared assets of my repo. Eventually by deleting all the comments in the file I got it to work? So I guess the issue was related to thepost-css
stage in the webpack rules?
I had the same issue and I managed to solve it by adding manually the css minimizer plugin
const { join } = require('path');
const getWebpackConfig = require('@nrwl/react/plugins/webpack');
const { getLessVars } = require('antd-theme-generator');
const AntDesignThemePlugin = require('antd-theme-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const antdVarFile = join(__dirname, './src/app/styles/theme.less');
module.exports = c => {
const config = getWebpackConfig(c);
config.optimization = {
minimizer: [new CssMinimizerPlugin()]
};
config.plugins = [
new AntDesignThemePlugin({
varFile: antdVarFile,
antDir: join(__dirname, '../../node_modules/antd'),
themeVariables: Object.keys(getLessVars(antdVarFile))
}),
...config.plugins
];
return config;
};
Now builds works!
Hope it helps 😄
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
We updated from nx 12 to nx 13. We opted into webpack 5 while using nx 12, to make sure our custom webpack-config will not break when updating, and it was working fine. But right now we get an error, unregarding we opted into webpack 5. The error occurs, while using a webpack plugin that creates a less file inside the production build. If
optimization
is false, it works. Otherwise the app will not compile a production build. The reproduction is very specific, since we use a plugin to generate a theme for our ant.design library of react-components. But I guess the errors origin is related to a loader configuration or similar, since it was working before with webpack 5 and nx 12.Expected Behavior
The flag
optimization
should work with a production build of a react application, when custom webpack plugins are used, that generate .less files.Steps to Reproduce
const antdVarFile = join(__dirname, '../../antd.less')
module.exports = (config) => { const cfg = getWebpackConfig(config)
cfg.plugins = [ ...cfg.plugins, new AntDesignThemePlugin({ antDir: join(__dirname, '../../node_modules/antd'), varFile: antdVarFile, themeVariables: Object.keys(getLessVars(antdVarFile)), }) ]
return cfg }
ERROR in color.less color.less from Css Minimizer plugin /project/color.less:1788:1: Unknown word You tried to parse Less with the standard CSS parser; try again with the postcss-less parser [color.less:1788,1] You tried to parse Less with the standard CSS parser; try again with the postcss-less parser