Skip to content

Commit

Permalink
build: dedupe theming scss bundle
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
devversion committed Apr 20, 2017
1 parent e73af7d commit 1fc9a3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"rollup": "^0.41.6",
"run-sequence": "^1.2.2",
"sass": "^0.5.0",
"scss-bundle": "^1.0.1",
"scss-bundle": "^2.0.1-beta.7",
"selenium-webdriver": "^3.1.0",
"sorcery": "^0.10.0",
"stylelint": "^7.8.0",
Expand Down
36 changes: 13 additions & 23 deletions tools/gulp/tasks/release.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import {spawn} from 'child_process';
import {existsSync, readFileSync, statSync, writeFileSync} from 'fs-extra';
import {basename, join} from 'path';
import {existsSync, statSync, writeFileSync} from 'fs-extra';
import {join} from 'path';
import {dest, src, task} from 'gulp';
import {inlineMetadataResources} from '../util/inline-resources';
import {execNodeTask, execTask, sequenceTask} from '../util/task_helpers';
import {execTask, sequenceTask} from '../util/task_helpers';
import {composeRelease} from '../util/package-build';
import {Bundler} from 'scss-bundle';
import {
COMPONENTS_DIR,
DIST_BUNDLES,
DIST_MATERIAL,
DIST_RELEASES,
DIST_ROOT,
LICENSE_BANNER,
PROJECT_ROOT,
} from '../constants';
import * as minimist from 'minimist';

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

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

// Glob that matches all files that might be imported multiple times.
// Necessary for deduping inside of scss-bundle.
const themingBundleDedupeGlob = join(COMPONENTS_DIR, '**/*.scss');

// Matches all pre-built theme css files
const prebuiltThemeGlob = join(DIST_MATERIAL, '**/theming/prebuilt/*.css');

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

/** Bundles all scss requires for theming into a single scss file in the root of the package. */
task(':bundle:theming-scss', execNodeTask(
'scss-bundle',
'scss-bundle', [
'-e', themingEntryPointPath,
'-d', themingBundlePath
], {silentStdout: true}
));
task(':bundle:theming-scss', () => {
new Bundler().Bundle(themingEntryPointPath, [themingBundleDedupeGlob]).then(result => {
writeFileSync(themingBundlePath, result.bundledContent);
});
});

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

/** Create a typing file that links to the bundled definitions of NGC. */
function createTypingFile() {
writeFileSync(join(releasePath, 'material.d.ts'),
LICENSE_BANNER + '\nexport * from "./typings/index";'
);
}

task(':publish:logout', execTask('npm', ['logout']));


Expand Down

0 comments on commit 1fc9a3a

Please sign in to comment.