build: dedupe theming scss bundle (#4174)

Fixes #3931
This commit is contained in:
Paul Gschwendtner
2017-04-21 03:45:01 +02:00
committed by Kara
parent c63cf87104
commit 7c81698e17
2 changed files with 16 additions and 24 deletions
+1 -1
View File
@@ -106,7 +106,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",
+15 -23
View File
@@ -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. */
@@ -32,6 +27,9 @@ const themingEntryPointPath = join(COMPONENTS_DIR, 'core', 'theming', '_all-them
// Output path for the scss theming bundle.
const themingBundlePath = join(releasePath, '_theming.scss');
// Matches all SCSS files in the library.
const allScssGlob = join(COMPONENTS_DIR, '**/*.scss');
// Matches all pre-built theme css files
const prebuiltThemeGlob = join(DIST_MATERIAL, '**/theming/prebuilt/*.css');
@@ -51,13 +49,14 @@ 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', () => {
// Instantiates the SCSS bundler and bundles all imports of the specified entry point SCSS file.
// A glob of all SCSS files in the library will be passed to the bundler. The bundler takes an
// array of globs, which will match SCSS files that will be only included once in the bundle.
new Bundler().Bundle(themingEntryPointPath, [allScssGlob]).then(result => {
writeFileSync(themingBundlePath, result.bundledContent);
});
});
/** Make sure we're logged in. */
task(':publish:whoami', execTask('npm', ['whoami'], {
@@ -65,13 +64,6 @@ task(':publish:whoami', execTask('npm', ['whoami'], {
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']));