Skip to content

Commit e66fee7

Browse files
committed
Fix #1082 exclude global styles by parameter
1 parent 4321368 commit e66fee7

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

gulpfile.babel.js

+2-17
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ gulp.task('js:app', () => {
3636
.pipe(gulp.dest(distPath + '/js'));
3737
});
3838

39-
/*jshint camelcase: false */
40-
var excludeDefaultStyles = process.env.npm_config_excludeDefaultStyles || false;
41-
4239
gulp.task('js:vendor', ['bower'], () => {
4340
return gulp.src(['lib/app/js/vendor/**/*.js'].concat(mainBowerFiles({filter: /\.js/})))
4441
.pipe(plumber())
@@ -50,7 +47,7 @@ gulp.task('bower', () => {
5047
return bower();
5148
});
5249

53-
gulp.task('copy:css', ['build:styleguide-app'], () => {
50+
gulp.task('copy:css', () => {
5451
return gulp.src('lib/app/css/**/*')
5552
.pipe(gulp.dest(distPath + '/css'));
5653
});
@@ -94,6 +91,7 @@ gulp.task('dev:generate', () => {
9491
rootPath: outputPath,
9592
overviewPath: 'README.md',
9693
styleVariables: 'lib/app/css/_styleguide_variables.css',
94+
excludeDefaultStyles: true,
9795
parsers: {
9896
css: 'postcss'
9997
}
@@ -127,19 +125,6 @@ gulp.task('dev:applystyles', () => {
127125
.pipe(gulp.dest(outputPath));
128126
});
129127

130-
gulp.task('build:styleguide-app', () => {
131-
var srcFiles = ['lib/app/css/_fontpath_and_mixin_definition.css'];
132-
133-
if (!excludeDefaultStyles) {
134-
srcFiles.push('lib/app/css/_styleguide_default_styles.css');
135-
}
136-
137-
srcFiles.push('lib/app/css/_custom_styles_mixin.css');
138-
return gulp.src(srcFiles)
139-
.pipe(concat('lib/app/css/styleguide-app.css'))
140-
.pipe(gulp.dest('.'));
141-
});
142-
143128
gulp.task('dev', ['dev:doc', 'dev:static', 'dev:applystyles'], () => {
144129
//Do intial full build and create styleguide
145130
runSequence('build:dist', 'dev:generate');

lib/modules/common.js

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function sanitizeOptions(opt) {
3131
basicAuth: opt.basicAuth || null,
3232
rootPath: opt.rootPath,
3333
readOnly: opt.readOnly || false,
34+
excludeDefaultStyles: opt.excludeDefaultStyles || false,
3435
parsers: opt.parsers || {
3536
sass: 'sass',
3637
scss: 'scss',

lib/styleguide.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
var path = require('path'),
1414
pug = require('pug'),
1515
through = require('through2'),
16+
concat = require('concat-files'),
1617
gulp = require('gulp'),
1718
rename = require('gulp-rename'),
1819
mustache = require('gulp-mustache'),
@@ -37,6 +38,7 @@ var path = require('path'),
3738
addSection = require('./modules/helpers/add-section'),
3839
sgServer = require('./server'),
3940
distPath = path.join(__dirname, 'dist'),
41+
libPath = path.join(__dirname, 'lib'),
4042
fileHashes = {},
4143
pugCache,
4244
sgOptions, // global object for options
@@ -150,7 +152,7 @@ function replaceSectionReferences(json) {
150152
}
151153

152154
function copyUsedOptionsToJsonConfig(opt, json) {
153-
var used = ['appRoot', 'extraHead', 'beforeBody', 'afterBody', 'commonClass', 'title', 'disableEncapsulation', 'disableHtml5Mode', 'readOnly', 'sideNav', 'afterSections', 'showMarkupSection', 'hideSubsectionsOnMainSection', 'additionalNgDependencies'];
155+
var used = ['appRoot', 'extraHead', 'beforeBody', 'afterBody', 'commonClass', 'title', 'disableEncapsulation', 'disableHtml5Mode', 'readOnly', 'sideNav', 'afterSections', 'showMarkupSection', 'hideSubsectionsOnMainSection', 'excludeDefaultStyles','additionalNgDependencies'];
154156
json.config = {};
155157
used.forEach(function(prop) {
156158
json.config[prop] = _.cloneDeep(opt[prop]);
@@ -329,7 +331,18 @@ module.exports.generate = function(options) {
329331
overviewProcessed,
330332
filesCopied,
331333
favIcon,
332-
indexHtmlProcessed;
334+
indexHtmlProcessed,
335+
srcFiles;
336+
337+
srcFiles = [distPath + '/css/_fontpath_and_mixin_definition.css'];
338+
339+
if (!opt.excludeDefaultStyles) {
340+
srcFiles.push(distPath + '/css/_styleguide_default_styles.css');
341+
}
342+
343+
srcFiles.push(distPath + '/css/_custom_styles_mixin.css');
344+
concat(srcFiles, libPath + '/app/css/styleguide-app.css');
345+
concat(srcFiles, distPath + '/css/styleguide-app.css');
333346

334347
overviewProcessed = processOverviewMarkdown(opt);
335348
var cssSrc = [distPath + '/css/styleguide-app.css', distPath + '/css/styleguide_helper_elements.css'];
@@ -339,7 +352,7 @@ module.exports.generate = function(options) {
339352
//gulp.src([distPath + '/**', '!' + distPath + '/index.html', + '!' + distPath + '**/*.css'])
340353
var copySrc = [distPath + '/**', '!' + distPath + '/index.html'];
341354

342-
copySrc = copySrc.concat(cssSrc.map(function(item){
355+
copySrc = copySrc.concat(cssSrc.map(function(item) {
343356
return '!' + item;
344357
}));
345358

0 commit comments

Comments
 (0)