Skip to content

Commit 1fc9a3a

Browse files
committed
build: dedupe theming scss bundle
* Updates to a more recent version of SCSS-bundle that has support for deduping. The dedupe process is very naive and only disallows importing a file multiple times. * Switches to the programmatic API of `scss-bundle` * Removes unused functions and imports / leftovers. Fixes #3931
1 parent e73af7d commit 1fc9a3a

File tree

2 files changed

+14
-24
lines changed

2 files changed

+14
-24
lines changed

package.json

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

tools/gulp/tasks/release.ts

Lines changed: 13 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,10 @@ 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+
// Glob that matches all files that might be imported multiple times.
31+
// Necessary for deduping inside of scss-bundle.
32+
const themingBundleDedupeGlob = join(COMPONENTS_DIR, '**/*.scss');
33+
3534
// Matches all pre-built theme css files
3635
const prebuiltThemeGlob = join(DIST_MATERIAL, '**/theming/prebuilt/*.css');
3736

@@ -51,27 +50,18 @@ task(':package:theming', [':bundle:theming-scss'], () => {
5150
});
5251

5352
/** 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-
));
53+
task(':bundle:theming-scss', () => {
54+
new Bundler().Bundle(themingEntryPointPath, [themingBundleDedupeGlob]).then(result => {
55+
writeFileSync(themingBundlePath, result.bundledContent);
56+
});
57+
});
6158

6259
/** Make sure we're logged in. */
6360
task(':publish:whoami', execTask('npm', ['whoami'], {
6461
silent: true,
6562
errMessage: 'You must be logged in to publish.'
6663
}));
6764

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-
7565
task(':publish:logout', execTask('npm', ['logout']));
7666

7767

0 commit comments

Comments
 (0)