Skip to content

Commit d203e38

Browse files
fix review comments
1 parent 026df10 commit d203e38

6 files changed

Lines changed: 54 additions & 10 deletions

File tree

.github/workflows/themebuilder_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252

5353
- name: Build etalon bundles
5454
working-directory: ./packages/devextreme-scss
55-
run: pnpm --workspace-root nx run devextreme-scss:build:ci
55+
run: pnpm --workspace-root nx build:ci devextreme-scss
5656

5757
- name: Build
5858
working-directory: ./packages/devextreme-themebuilder

packages/devextreme-scss/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"build": "pnpm --workspace-root nx build devextreme-scss",
1414
"lint": "stylelint scss/widgets",
1515
"test": "jest --no-coverage --runInBand --config=./tests/jest.config.json",
16-
"watch": "pnpm --workspace-root nx run devextreme-scss:watch"
16+
"watch": "pnpm --workspace-root nx run devextreme-scss --target=watch"
1717
},
1818
"version": "26.1.0"
1919
}

packages/devextreme-themebuilder/tests/modules/post-compiler.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ describe('PostCompiler', () => {
3838
+ 'css');
3939
});
4040

41+
const themeBuilderInfoHeader = '/** Generated by the DevExpress ThemeBuilder\n'
42+
+ '* Version: 1.1.1\n'
43+
+ '* http://js.devexpress.com/ThemeBuilder/\n'
44+
+ '*/\n\n';
45+
46+
test('addInfoHeader - append after body, @charset glued to :root (CompileManager parity)', () => {
47+
expect(addInfoHeader('@charset "utf-8";:root{}', '1.1.1', true))
48+
.toBe('@charset "UTF-8";:root{}\n'
49+
+ themeBuilderInfoHeader);
50+
});
51+
52+
test('addInfoHeader - append after body, strips newline between @charset and @import', () => {
53+
expect(addInfoHeader('@charset "UTF-8";\n@import url(https://example.com/a.css);', '1.1.1', true))
54+
.toBe('@charset "UTF-8";@import url(https://example.com/a.css);\n'
55+
+ themeBuilderInfoHeader);
56+
});
57+
4158
test('cleanCss', async () => {
4259
expect(await cleanCss('.c1 { color: #F00; } .c2 { color: #F00; }'))
4360
.toBe('.c1,\n.c2 {\n color: red;\n}');

packages/devextreme/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
"build:testcafe": "cross-env DEVEXTREME_TEST_CI=TRUE BUILD_ESM_PACKAGE=true BUILD_TESTCAFE=TRUE gulp default",
234234
"build-npm-devextreme": "cross-env BUILD_ESM_PACKAGE=true gulp default",
235235
"build-dist": "cross-env BUILD_ESM_PACKAGE=true gulp default --uglify",
236-
"build-themes": "pnpm --workspace-root nx run devextreme-scss:build:themes && pnpm --workspace-root nx run devextreme-scss:copy:assets",
236+
"build-themes": "pnpm --workspace-root nx build:themes devextreme-scss && pnpm --workspace-root nx copy:assets devextreme-scss",
237237
"build:react": "gulp generate-react",
238238
"build:react:watch": "gulp generate-react-watch",
239239
"build:react:typescript": "gulp generate-react-typescript",

packages/nx-infra-plugin/src/executors/scss-build/executor.e2e.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@ function createMockModules(workspaceRoot: string, projectRoot: string): void {
6464
].join('\n'),
6565
'utf8',
6666
);
67+
68+
const chokidarDir = path.join(workspaceNodeModules, 'chokidar');
69+
fs.mkdirSync(chokidarDir, { recursive: true });
70+
fs.writeFileSync(
71+
path.join(chokidarDir, 'index.js'),
72+
[
73+
'module.exports = {',
74+
' watch: function watch() {',
75+
' return {',
76+
' on: function on() { return this; },',
77+
' close: function close() { return Promise.resolve(); },',
78+
' };',
79+
' },',
80+
'};',
81+
'',
82+
].join('\n'),
83+
'utf8',
84+
);
6785
}
6886

6987
async function setupProjectStructure(workspaceRoot: string): Promise<string> {

packages/nx-infra-plugin/src/executors/scss-build/executor.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ interface BuildDependencies {
3030
sass: any;
3131
postcss: any;
3232
autoprefixer: (options?: { overrideBrowserslist?: string[] }) => any;
33+
chokidar: {
34+
watch: (
35+
paths: string | string[],
36+
options?: Record<string, unknown>,
37+
) => {
38+
on: (event: string, handler: (...args: any[]) => void) => unknown;
39+
close: () => Promise<void> | void;
40+
};
41+
};
3342
CleanCss: new (options: unknown) => { minify: (input: string) => { styles: string } };
3443
themeOptions: { getThemes: () => Array<[string, string, string, string?]> };
3544
cleanCssSanitizeOptions: unknown;
@@ -124,6 +133,7 @@ function loadDependencies(projectRoot: string): BuildDependencies {
124133
sass: projectRequire('sass-embedded'),
125134
postcss: workspaceRequire('postcss'),
126135
autoprefixer: workspaceRequire('autoprefixer'),
136+
chokidar: workspaceRequire('chokidar'),
127137
CleanCss: workspaceRequire('clean-css'),
128138
themeOptions: projectRequire(path.resolve(projectRoot, 'build/theme-options.cjs')) as {
129139
getThemes: () => Array<[string, string, string, string?]>;
@@ -288,14 +298,15 @@ async function runWatchBuild(
288298
const cssOutputDir = path.resolve(projectRoot, options.cssOutputDir || DEFAULT_CSS_OUTPUT_DIR);
289299
const watchDir = path.resolve(projectRoot, 'scss');
290300
const watchBundleNames = getWatchBundleNames(options);
301+
const minifyProfile: MinifyProfile = options.mode === 'ci' ? 'ci' : 'all';
291302

292303
const rebuild = async (): Promise<void> => {
293304
await generateScssBundles(projectRoot, bundlesDir, deps);
294305
await ensureDir(cssOutputDir);
295306

296307
const sources = resolveSourcesByBundleNames(projectRoot, bundlesDir, watchBundleNames);
297308
for (const source of sources) {
298-
await compileFile(source, cssOutputDir, 'all', deps, projectRoot);
309+
await compileFile(source, cssOutputDir, minifyProfile, deps, projectRoot);
299310
}
300311

301312
await copyAssets(projectRoot, cssOutputDir);
@@ -331,15 +342,13 @@ async function runWatchBuild(
331342
}, 200);
332343
};
333344

334-
const watcher = fs.watch(watchDir, { recursive: true }, (_eventType, fileName) => {
335-
if (!fileName || !fileName.endsWith('.scss')) {
336-
return;
337-
}
338-
scheduleRebuild();
345+
const watcher = deps.chokidar.watch(path.join(watchDir, '**/*.scss'), {
346+
ignoreInitial: true,
339347
});
348+
watcher.on('all', scheduleRebuild);
340349

341350
const stopWatcher = () => {
342-
watcher.close();
351+
void watcher.close();
343352
if (timer) {
344353
clearTimeout(timer);
345354
}

0 commit comments

Comments
 (0)