mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Always use uglify during build
It makes very little difference between "npm run build" and "npm run build --development" (both under a second), since the gulp pipeline is smart enough to only uglify the new bits. Creating different dist files with "--development" is causing grief during pull requests, since most devs will add the changed files without reviewing them. It also means you can commit without stopping your "watch" npm task.
This commit is contained in:
parent
23292e22b6
commit
0789ad2fd9
38
gulpfile.js
38
gulpfile.js
@ -4,7 +4,6 @@ var gulp = require('gulp'),
|
||||
notify = require('gulp-notify'),
|
||||
uglify = require('gulp-uglify');
|
||||
gulpUtil = require('gulp-util'),
|
||||
gulpif = require('gulp-if'),
|
||||
browserify = require('browserify'),
|
||||
babelify = require('babelify'),
|
||||
watchify = require('watchify'),
|
||||
@ -23,17 +22,25 @@ var PATHS = {
|
||||
CMS_JAVASCRIPT_DIST: './javascript/dist'
|
||||
};
|
||||
|
||||
var browserifyOptions = {
|
||||
cache: {},
|
||||
packageCache: {},
|
||||
poll: true,
|
||||
plugin: [watchify]
|
||||
};
|
||||
|
||||
var isDev = typeof process.env.npm_config_development !== 'undefined';
|
||||
|
||||
process.env.NODE_ENV = isDev ? 'development' : 'production';
|
||||
|
||||
var babelifyOptions = {
|
||||
presets: ['es2015', 'es2015-ie', 'react'],
|
||||
plugins: ['transform-object-assign'],
|
||||
ignore: /(node_modules|thirdparty)/,
|
||||
comments: false
|
||||
};
|
||||
|
||||
const browserifyOptions = {};
|
||||
if (isDev) {
|
||||
browserifyOptions.debug = true;
|
||||
browserifyOptions.cache = {};
|
||||
browserifyOptions.packageCache = {};
|
||||
browserifyOptions.plugin = [watchify];
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the passed JavaScript files to UMD modules.
|
||||
*
|
||||
@ -63,17 +70,6 @@ if (!semver.satisfies(process.versions.node, packageJson.engines.node)) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (isDev) {
|
||||
browserifyOptions.debug = true;
|
||||
}
|
||||
|
||||
var babelifyOptions = {
|
||||
presets: ['es2015', 'es2015-ie', 'react'],
|
||||
plugins: ['transform-object-assign'],
|
||||
ignore: /(node_modules|thirdparty)/,
|
||||
comments: false
|
||||
};
|
||||
|
||||
gulp.task('build', ['umd-cms', 'umd-watch', 'bundle-legacy']);
|
||||
|
||||
gulp.task('bundle-legacy', function bundleLeftAndMain() {
|
||||
@ -91,7 +87,7 @@ gulp.task('bundle-legacy', function bundleLeftAndMain() {
|
||||
.pipe(source(bundleFileName))
|
||||
.pipe(buffer())
|
||||
.pipe(sourcemaps.init({ loadMaps: true }))
|
||||
.pipe(gulpif(!isDev, uglify()))
|
||||
.pipe(uglify())
|
||||
.pipe(sourcemaps.write('./'))
|
||||
.pipe(gulp.dest(PATHS.CMS_JAVASCRIPT_DIST));
|
||||
});
|
||||
@ -101,5 +97,7 @@ gulp.task('umd-cms', function () {
|
||||
});
|
||||
|
||||
gulp.task('umd-watch', function () {
|
||||
if (isDev) {
|
||||
gulp.watch(PATHS.CMS_JAVASCRIPT_SRC + '/*.js', ['umd-cms']);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user