Skip to content

Commit 7c81698

Browse files
devversionkara
authored andcommitted
build: dedupe theming scss bundle (#4174)
Fixes #3931
1 parent c63cf87 commit 7c81698

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"rollup": "^0.41.6",
107107
"run-sequence": "^1.2.2",
108108
"sass": "^0.5.0",
109-
"scss-bundle": "^1.0.1",
109+
"scss-bundle": "^2.0.1-beta.7",
110110
"selenium-webdriver": "^3.1.0",
111111
"sorcery": "^0.10.0",
112112
"stylelint": "^7.8.0",

tools/gulp/tasks/release.ts

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
import {spawn} from 'child_process';
2-
import {existsSync, readFileSync, statSync, writeFileSync} from 'fs-extra';
3-
import {basename, join} from 'path';
2+
import {existsSync, statSync, writeFileSync} from 'fs-extra';
3+
import {join} from 'path';
44
import {dest, src, task} from 'gulp';
5-
import {inlineMetadataResources} from '../util/inline-resources';
6-
import {execNodeTask, execTask, sequenceTask} from '../util/task_helpers';
5+
import {execTask, sequenceTask} from '../util/task_helpers';
76
import {composeRelease} from '../util/package-build';
7+
import {Bundler} from 'scss-bundle';
88
import {
99
COMPONENTS_DIR,
10-
DIST_BUNDLES,
1110
DIST_MATERIAL,
1211
DIST_RELEASES,
13-
DIST_ROOT,
14-
LICENSE_BANNER,
15-
PROJECT_ROOT,
1612
} from '../constants';
1713
import * as minimist from 'minimist';
1814

1915
// There are no type definitions available for these imports.
20-
const glob = require('glob');
2116
const gulpRename = require('gulp-rename');
2217

2318
/** Parse command-line arguments for release task. */
@@ -32,6 +27,9 @@ const themingEntryPointPath = join(COMPONENTS_DIR, 'core', 'theming', '_all-them
3227
// Output path for the scss theming bundle.
3328
const themingBundlePath = join(releasePath, '_theming.scss');
3429

30+
// Matches all SCSS files in the library.
31+
const allScssGlob = join(COMPONENTS_DIR, '**/*.scss');
32+
3533
// Matches all pre-built theme css files
3634
const prebuiltThemeGlob = join(DIST_MATERIAL, '**/theming/prebuilt/*.css');
3735

@@ -51,27 +49,21 @@ task(':package:theming', [':bundle:theming-scss'], () => {
5149
});
5250

5351
/** Bundles all scss requires for theming into a single scss file in the root of the package. */
54-
task(':bundle:theming-scss', execNodeTask(
55-
'scss-bundle',
56-
'scss-bundle', [
57-
'-e', themingEntryPointPath,
58-
'-d', themingBundlePath
59-
], {silentStdout: true}
60-
));
52+
task(':bundle:theming-scss', () => {
53+
// Instantiates the SCSS bundler and bundles all imports of the specified entry point SCSS file.
54+
// A glob of all SCSS files in the library will be passed to the bundler. The bundler takes an
55+
// array of globs, which will match SCSS files that will be only included once in the bundle.
56+
new Bundler().Bundle(themingEntryPointPath, [allScssGlob]).then(result => {
57+
writeFileSync(themingBundlePath, result.bundledContent);
58+
});
59+
});
6160

6261
/** Make sure we're logged in. */
6362
task(':publish:whoami', execTask('npm', ['whoami'], {
6463
silent: true,
6564
errMessage: 'You must be logged in to publish.'
6665
}));
6766

68-
/** Create a typing file that links to the bundled definitions of NGC. */
69-
function createTypingFile() {
70-
writeFileSync(join(releasePath, 'material.d.ts'),
71-
LICENSE_BANNER + '\nexport * from "./typings/index";'
72-
);
73-
}
74-
7567
task(':publish:logout', execTask('npm', ['logout']));
7668

7769

0 commit comments

Comments
 (0)