Skip to content

Commit e81bdf4

Browse files
Обмочевский Владислав ВячеславовичОбмочевский Владислав Вячеславович
authored andcommitted
feat(postcss): move insertPlugin in createPostcssConfig
1 parent 6f308c8 commit e81bdf4

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

packages/arui-scripts/src/configs/postcss.config.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import path from 'path';
2+
3+
import { insertPlugin } from '../plugins/insert-plugin';
4+
import { postCssGlobalData } from '../plugins/postcss-global-data/postcss-global-data';
5+
16
import config from './app-configs';
27
import supportingBrowsers from './supporting-browsers';
38
/**
@@ -10,13 +15,18 @@ export function createPostcssConfig(
1015
plugins: string[],
1116
options: Record<string, unknown>,
1217
): string[] | unknown[] {
13-
return plugins.map((pluginName) => {
18+
const postcssPlugins = plugins.map((pluginName) => {
1419
if (pluginName in options) {
1520
return [pluginName, options[pluginName]];
1621
}
1722

1823
return pluginName;
1924
});
25+
26+
// добавляем postCssGlobalData плагин перед postcss-custom-media
27+
return insertPlugin(postcssPlugins, 'postcss-custom-media', postCssGlobalData({
28+
files: [path.join(__dirname, 'mq.css'), config.componentsTheme].filter(Boolean) as string[]
29+
}));
2030
}
2131

2232
export const postcssPlugins = [

packages/arui-scripts/src/configs/webpack.client.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import { WebpackDeduplicationPlugin } from 'webpack-deduplication-plugin';
2020
import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
2121

2222
import { AruiRuntimePlugin, getInsertCssRuntimeMethod } from '../plugins/arui-runtime';
23-
import { insertPlugin } from '../plugins/insert-plugin';
24-
import { postCssGlobalData } from '../plugins/postcss-global-data/postcss-global-data';
2523
import { htmlTemplate } from '../templates/html.template';
2624

2725
import { getImageMin } from './config-extras/minimizers';
@@ -287,10 +285,7 @@ export const createSingleClientWebpackConfig = (
287285
loader: require.resolve('postcss-loader'),
288286
options: {
289287
postcssOptions: {
290-
// добавляем postCssGlobalData плагин перед postcss-custom-media
291-
plugins: insertPlugin(postcssConf, 'postcss-custom-media', postCssGlobalData({
292-
files: [path.join(__dirname, 'mq.css'), configs.componentsTheme].filter(Boolean) as string[]
293-
}))
288+
plugins: postcssConf,
294289
},
295290
},
296291
},
@@ -318,10 +313,7 @@ export const createSingleClientWebpackConfig = (
318313
loader: require.resolve('postcss-loader'),
319314
options: {
320315
postcssOptions: {
321-
// добавляем postCssGlobalData плагин перед postcss-custom-media
322-
plugins: insertPlugin(postcssConf, 'postcss-custom-media', postCssGlobalData({
323-
files: [path.join(__dirname, 'mq.css'), configs.componentsTheme].filter(Boolean) as string[]
324-
}))
316+
plugins: postcssConf,
325317
},
326318
},
327319
},

0 commit comments

Comments
 (0)