Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

angular: replace webpack rtl config with postcss file #28187

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions generators/angular/files-angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export const files = {
'jest.conf.js',
],
}),
clientRootTemplatesBlock({
condition: ctx => ctx.enableTranslation && ctx.enableI18nRTL,
templates: ['postcss.config.json'],
}),
],
webpack: [
clientRootTemplatesBlock({
Expand All @@ -63,10 +67,6 @@ export const files = {
condition: ctx => ctx.clientBundlerExperimentalEsbuild && ctx.enableTranslation,
templates: ['build-plugins/i18n-esbuild.mjs'],
}),
clientRootTemplatesBlock({
condition: ctx => ctx.clientBundlerExperimentalEsbuild && ctx.enableTranslation && ctx.enableI18nRTL,
templates: ['postcss.config.json'],
}),
clientSrcTemplatesBlock({
condition: ctx => ctx.clientBundlerExperimentalEsbuild && ctx.enableTranslation,
templates: ['i18n/index.ts'],
Expand Down
19 changes: 0 additions & 19 deletions generators/angular/templates/webpack/webpack.custom.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ const path = require('path');
<%_ if (enableTranslation) { _%>
const { hashElement } = require('folder-hash');
const MergeJsonWebpackPlugin = require('merge-jsons-webpack-plugin');
<%_ if (enableI18nRTL) { _%>
const postcssRTLCSS = require('postcss-rtlcss');
<%_ } _%>
<%_ } _%>
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
Expand Down Expand Up @@ -137,22 +134,6 @@ module.exports = async (config, options, targetOptions) => {
config.plugins.push(new CopyWebpackPlugin({ patterns }));
}

<%_ if (enableI18nRTL) { _%>
const scssRule = config.module.rules.find(x => x.test && x.test.toString().includes('scss'));
const uses = scssRule.rules.flatMap(r => r.use || r.oneOf.flatMap(o => o.use));
const postcssLoaderOptions = uses.filter(u => u.loader.includes('postcss-loader')).map(u => u.options);
postcssLoaderOptions.forEach(options => {
const generateOptions = options.postcssOptions;
options.postcssOptions = (loader) => {
const postcssOptions = generateOptions(loader);
postcssOptions.plugins.push(postcssRTLCSS());
return postcssOptions;
};
// https://github.com/angular/angular-cli/blob/4b9199d97f3bcb10710b5049b04d8a04436e2dd4/packages/angular_devkit/build_angular/src/webpack/configs/styles.ts#L201-L202
options.postcssOptions.config = false;
});

<%_ } _%>
config.plugins.push(
new webpack.DefinePlugin({
<%_ if (enableTranslation) { _%>
Expand Down
Loading