Skip to content

Commit e20b01c

Browse files
committed
Updating gulp to use predictable plugin ordering
1 parent 437a304 commit e20b01c

6 files changed

+40
-47
lines changed

dist/css/selectize.bootstrap3.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/css/selectize.bootstrap4.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/css/selectize.bootstrap5.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/css/selectize.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/css/selectize.default.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -154,27 +154,25 @@ const _compileLess = async () => {
154154
src(['src/less/**.less']).pipe(dest('dist/less'));
155155
src(['src/plugins/**/*.less']).pipe(rename(renameFileToParentDirName)).pipe(dest('dist/less/plugins'));
156156

157-
src([
158-
'src/less/selectize.less',
159-
'src/plugins/**/*.less'
160-
])
157+
let plugin_styles = [];
158+
159+
// Add in all plugin styles in a predictable order
160+
fs.readdirSync('src/plugins').sort().forEach((file) => {
161+
const path = `src/plugins/${file}/plugin.less`;
162+
if (fs.existsSync(path)) {
163+
plugin_styles.push(path);
164+
}
165+
});
166+
167+
src(['src/less/selectize.less', ...plugin_styles])
161168
.pipe(concat('selectize.legacy.css'))
162-
.pipe(less({
163-
paths: ['lib', 'src/less'],
164-
math: 'always'
165-
}))
169+
.pipe(less({ paths: ['lib', 'src/less'], math: 'always' }))
166170
.pipe(__wrapStyles())
167171
.pipe(dest('dist/css'));
168172

169-
src([
170-
'src/less/selectize.bootstrap2.less',
171-
'src/plugins/**/*.less'
172-
])
173+
src(['src/less/selectize.bootstrap2.less', ...plugin_styles])
173174
.pipe(concat('selectize.bootstrap2.css'))
174-
.pipe(less({
175-
paths: ['lib', 'src/less'],
176-
math: 'always'
177-
}))
175+
.pipe(less({ paths: ['lib', 'src/less'], math: 'always' }))
178176
.pipe(__wrapStyles())
179177
.pipe(dest('dist/css'));
180178
}
@@ -185,38 +183,33 @@ const _compileSass = async () => {
185183
.pipe(dest('dist/scss'));
186184
src(['src/plugins/**/*.scss']).pipe(rename(renameFileToParentDirName)).pipe(dest('dist/scss/plugins'));
187185

188-
src([
189-
'src/scss/selectize.scss',
190-
'src/plugins/**/*.scss'
191-
])
186+
let plugin_styles = [];
187+
188+
// Add in all plugin styles in a predictable order
189+
fs.readdirSync('src/plugins').sort().forEach((file) => {
190+
const path = `src/plugins/${file}/plugin.scss`;
191+
if (fs.existsSync(path)) {
192+
plugin_styles.push(path);
193+
}
194+
});
195+
196+
src(['src/scss/selectize.scss', ...plugin_styles])
192197
.pipe(concat('selectize.css'))
193-
.pipe(sass({
194-
includePaths: ['lib', 'src/scss'],
195-
}).on('error', sass.logError))
198+
.pipe(sass({ includePaths: ['lib', 'src/scss'], }).on('error', sass.logError))
196199
.pipe(__wrapStyles())
197200
.pipe(dest('dist/css'));
198201

199-
src([
200-
'src/scss/selectize.default.scss',
201-
'src/plugins/**/*.scss'
202-
])
202+
src(['src/scss/selectize.default.scss', ...plugin_styles])
203203
.pipe(concat('selectize.default.css'))
204-
.pipe(sass({
205-
includePaths: ['lib', 'src/scss'],
206-
}).on('error', sass.logError))
204+
.pipe(sass({ includePaths: ['lib', 'src/scss'], }).on('error', sass.logError))
207205
.pipe(__wrapStyles())
208206
.pipe(dest('dist/css'));
209207

210208
// build the bootstrap base sccss styles
211209
for (let bs_version = 3; bs_version <= 5; bs_version++) {
212-
src([
213-
'src/scss/selectize.bootstrap' + bs_version + '.scss',
214-
'src/plugins/**/*.scss'
215-
])
210+
src(['src/scss/selectize.bootstrap' + bs_version + '.scss', ...plugin_styles])
216211
.pipe(concat('selectize.bootstrap' + bs_version + '.css'))
217-
.pipe(sass({
218-
includePaths: ['lib', 'src/scss'],
219-
}).on('error', sass.logError))
212+
.pipe(sass({ includePaths: ['lib', 'src/scss'], }).on('error', sass.logError))
220213
.pipe(__wrapStyles())
221214
.pipe(dest('dist/css'));
222215
}

0 commit comments

Comments
 (0)