Update gulpfile.js and deprecate elixir
This commit is contained in:
parent
b873ffef9c
commit
b5a857ef68
120
gulpfile.js
120
gulpfile.js
@ -1,28 +1,21 @@
|
|||||||
/*
|
|
||||||
* @Author: printempw
|
|
||||||
* @Date: 2016-07-21 13:38:26
|
|
||||||
* @Last Modified by: g-plane
|
|
||||||
* @Last Modified time: 2017-04-26 15:39:46
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var gulp = require('gulp'),
|
var gulp = require('gulp'),
|
||||||
babel = require('gulp-babel'),
|
babel = require('gulp-babel'),
|
||||||
elixir = require('laravel-elixir'),
|
uglify = require('gulp-uglify'),
|
||||||
uglify = require('gulp-uglify'),
|
sass = require('gulp-sass'),
|
||||||
sass = require('gulp-sass'),
|
cleanCss = require('gulp-clean-css'),
|
||||||
cleanCss = require('gulp-clean-css'),
|
del = require('del'),
|
||||||
del = require('del'),
|
concat = require('gulp-concat'),
|
||||||
zip = require('gulp-zip'),
|
zip = require('gulp-zip'),
|
||||||
notify = require('gulp-notify');
|
replace = require('gulp-batch-replace'),
|
||||||
|
notify = require('gulp-notify'),
|
||||||
require('laravel-elixir-replace');
|
runSequence = require('run-sequence');
|
||||||
|
|
||||||
var version = require('./package.json').version;
|
var version = require('./package.json').version;
|
||||||
|
|
||||||
var srcPath = 'resources/assets/src/';
|
var srcPath = 'resources/assets/src';
|
||||||
var distPath = 'resources/assets/dist/';
|
var distPath = 'resources/assets/dist';
|
||||||
|
|
||||||
var vendorScripts = [
|
var vendorScripts = [
|
||||||
'jquery/dist/jquery.min.js',
|
'jquery/dist/jquery.min.js',
|
||||||
@ -55,7 +48,7 @@ var styleReplacements = [
|
|||||||
['blue@2x.png', '"../images/blue@2x.png"'],
|
['blue@2x.png', '"../images/blue@2x.png"'],
|
||||||
['../img/loading.gif', '"../images/loading.gif"'],
|
['../img/loading.gif', '"../images/loading.gif"'],
|
||||||
['../img/loading-sm.gif', '"../images/loading-sm.gif"'],
|
['../img/loading-sm.gif', '"../images/loading-sm.gif"'],
|
||||||
['@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic);', ''],
|
[/@import url\((.*)italic\);/g, ''],
|
||||||
];
|
];
|
||||||
|
|
||||||
var scriptReplacements = [
|
var scriptReplacements = [
|
||||||
@ -76,50 +69,67 @@ var images = [
|
|||||||
'bootstrap-fileinput/img/loading-sm.gif',
|
'bootstrap-fileinput/img/loading-sm.gif',
|
||||||
];
|
];
|
||||||
|
|
||||||
elixir.config.sourcemaps = false;
|
// aka. `yarn run build`
|
||||||
|
gulp.task('default', ['build']);
|
||||||
|
|
||||||
elixir((mix) => {
|
// Build the things!
|
||||||
mix // compile sass files & ES6 scripts first
|
gulp.task('build', function (callback) {
|
||||||
.task('compile-es6')
|
runSequence('clean', ['compile-es6', 'compile-sass'], 'publish-vendor', callback);
|
||||||
.task('compile-sass')
|
|
||||||
|
|
||||||
.scripts(convertNpmRelativePath(vendorScripts), distPath + 'js/app.js', './')
|
|
||||||
.styles(convertNpmRelativePath(vendorStyles), distPath + 'css/style.css', './')
|
|
||||||
.replace(distPath + 'css/style.css', styleReplacements)
|
|
||||||
.replace(distPath + 'js/app.js', scriptReplacements)
|
|
||||||
|
|
||||||
// copy fonts & images
|
|
||||||
.copy(convertNpmRelativePath(fonts), distPath + 'fonts/')
|
|
||||||
.copy(convertNpmRelativePath(images), distPath + 'images/')
|
|
||||||
.copy(convertNpmRelativePath(['admin-lte/dist/css/skins']), distPath + 'css/skins')
|
|
||||||
.copy(
|
|
||||||
['skin-preview/**', 'Chart.min.js'].map(relativePath => `${srcPath}vendor/${relativePath}`),
|
|
||||||
distPath + 'js/'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// compile sass
|
// Concentrate all vendor scripts & styles to one dist file
|
||||||
|
gulp.task('publish-vendor', ['compile-es6'], callback => {
|
||||||
|
// JavaScript files
|
||||||
|
gulp.src(convertNpmRelativePath(vendorScripts))
|
||||||
|
.pipe(concat('app.js'))
|
||||||
|
.pipe(replace(scriptReplacements))
|
||||||
|
.pipe(gulp.dest(`${distPath}/js/`));
|
||||||
|
// CSS files
|
||||||
|
gulp.src(convertNpmRelativePath(vendorStyles))
|
||||||
|
.pipe(concat('style.css'))
|
||||||
|
.pipe(replace(styleReplacements))
|
||||||
|
.pipe(gulp.dest(`${distPath}/css/`));
|
||||||
|
// Fonts
|
||||||
|
gulp.src(convertNpmRelativePath(fonts))
|
||||||
|
.pipe(gulp.dest(`${distPath}/fonts/`));
|
||||||
|
// Images
|
||||||
|
gulp.src(convertNpmRelativePath(images))
|
||||||
|
.pipe(gulp.dest(`${distPath}/images/`));
|
||||||
|
// AdminLTE skins
|
||||||
|
gulp.src('node_modules/admin-lte/dist/css/skins/**')
|
||||||
|
.pipe(gulp.dest(`${distPath}/css/skins/`));
|
||||||
|
// 3D skin preview
|
||||||
|
gulp.src(['skin-preview/**', 'Chart.min.js'].map(path => `${srcPath}/vendor/${path}`))
|
||||||
|
.pipe(gulp.dest(`${distPath}/js/`));
|
||||||
|
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Compile sass to css
|
||||||
gulp.task('compile-sass', () => {
|
gulp.task('compile-sass', () => {
|
||||||
gulp.src(srcPath + 'sass/*.scss')
|
return gulp.src(`${srcPath}/sass/*.scss`)
|
||||||
.pipe(sass().on('error', sass.logError))
|
.pipe(sass().on('error', sass.logError))
|
||||||
.pipe(cleanCss())
|
.pipe(cleanCss())
|
||||||
.pipe(gulp.dest(distPath + 'css'));
|
.pipe(gulp.dest(`${distPath}/css`));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Compile ES6 scripts to ES5
|
||||||
gulp.task('compile-es6', () => {
|
gulp.task('compile-es6', () => {
|
||||||
gulp.src(srcPath + 'js/*.js')
|
return gulp.src(`${srcPath}/js/*.js`)
|
||||||
.pipe(babel({ presets: ['es2015'] }))
|
.pipe(babel({ presets: ['es2015'] }))
|
||||||
.pipe(uglify())
|
.pipe(uglify())
|
||||||
.pipe(gulp.dest(distPath + 'js'));
|
.pipe(gulp.dest(`${distPath}/js`));
|
||||||
});
|
});
|
||||||
|
|
||||||
// delete cache files
|
// Delete cache files
|
||||||
gulp.task('clear', () => {
|
gulp.task('clean', () => {
|
||||||
clearCache();
|
clearCache();
|
||||||
clearDist();
|
|
||||||
|
return clearDist();
|
||||||
});
|
});
|
||||||
|
|
||||||
// release
|
// Release archive file
|
||||||
|
// aka. `yarn run release`
|
||||||
gulp.task('zip', () => {
|
gulp.task('zip', () => {
|
||||||
clearCache();
|
clearCache();
|
||||||
|
|
||||||
@ -166,15 +176,15 @@ gulp.task('zip', () => {
|
|||||||
|
|
||||||
gulp.task('watch', () => {
|
gulp.task('watch', () => {
|
||||||
// watch .scss files
|
// watch .scss files
|
||||||
gulp.watch(srcPath + 'sass/*.scss', ['compile-sass'], () => notify({ message: 'Sass files compiled!' }));
|
gulp.watch(`${srcPath}/sass/*.scss`, ['compile-sass'], () => notify({ message: 'Sass files compiled!' }));
|
||||||
// watch .js files
|
// watch .js files
|
||||||
gulp.watch(srcPath + 'js/*.js', ['compile-es6'], () => notify({ message: 'ES6 scripts compiled!' }));
|
gulp.watch(`${srcPath}/js/*.js`, ['compile-es6'], () => notify({ message: 'ES6 scripts compiled!' }));
|
||||||
gulp.watch(srcPath + 'js/general.js', ['scripts']);
|
gulp.watch(`${srcPath}/js/general.js`, ['build']);
|
||||||
});
|
});
|
||||||
|
|
||||||
function convertNpmRelativePath(paths) {
|
function convertNpmRelativePath(paths) {
|
||||||
return paths.map(relativePath => {
|
return paths.map(relativePath => {
|
||||||
return relativePath.startsWith('resources') ? relativePath : ('node_modules/' + relativePath);
|
return relativePath.startsWith('resources') ? relativePath : `node_modules/${relativePath}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +201,5 @@ function clearCache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clearDist() {
|
function clearDist() {
|
||||||
return del([
|
return del([`${distPath}/**/*`]);
|
||||||
distPath + '**/*'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
21
package.json
21
package.json
@ -10,23 +10,24 @@
|
|||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prod": "gulp --production",
|
"build": "gulp build",
|
||||||
|
"release": "gulp release",
|
||||||
"dev": "gulp watch"
|
"dev": "gulp watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-preset-es2015": "^6.24.1",
|
"babel-preset-es2015": "^6.24.1",
|
||||||
|
"del": "^3.0.0",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"gulp-babel": "^6.1.2",
|
"gulp-babel": "^6.1.2",
|
||||||
"gulp-clean-css": "^2.4.0",
|
"gulp-batch-replace": "^0.0.0",
|
||||||
|
"gulp-clean-css": "^3.6.0",
|
||||||
"gulp-concat": "^2.6.1",
|
"gulp-concat": "^2.6.1",
|
||||||
"gulp-jshint": "^2.0.4",
|
"gulp-eslint": "^4.0.0",
|
||||||
"gulp-rename": "^1.2.2",
|
"gulp-notify": "^3.0.0",
|
||||||
"gulp-replace": "^0.5.4",
|
"gulp-sass": "^3.1.0",
|
||||||
"gulp-ruby-sass": "^2.1.1",
|
"gulp-uglify": "^3.0.0",
|
||||||
"gulp-uglify": "^1.5.4",
|
"gulp-zip": "^4.0.0",
|
||||||
"gulp-zip": "^3.2.0",
|
"run-sequence": "^2.0.0"
|
||||||
"laravel-elixir": "^6.0.0-15",
|
|
||||||
"laravel-elixir-replace": "^1.1.2"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"admin-lte": "^2.3.11",
|
"admin-lte": "^2.3.11",
|
||||||
|
2
plugins
2
plugins
@ -1 +1 @@
|
|||||||
Subproject commit d1b46c53773b8e4ccfc049d163d9977bae0e4fef
|
Subproject commit 4f2b157b7fad1eb2c753faad19ac92c424cbecd5
|
Loading…
Reference in New Issue
Block a user