gulpfile eslinted
This commit is contained in:
1 parent
b68ed4c8ed
commit
4944e8cd4f
1 file changed
+99
-103
+99
-103
@@ -1,143 +1,139 @@
|
|||||||
import gulp from 'gulp';
|
import gulp from 'gulp'
|
||||||
import postcss from 'gulp-postcss';
|
import postcss from 'gulp-postcss'
|
||||||
import sass from 'gulp-sass';
|
import sass from 'gulp-sass'
|
||||||
import imageMin from 'gulp-imagemin';
|
import imageMin from 'gulp-imagemin'
|
||||||
import uglify from 'gulp-uglify';
|
import uglify from 'gulp-uglify'
|
||||||
import concat from 'gulp-concat';
|
import concat from 'gulp-concat'
|
||||||
import webpack from 'webpack-stream';
|
import webpack from 'webpack-stream'
|
||||||
import named from 'vinyl-named';
|
import named from 'vinyl-named'
|
||||||
import autoprefixer from 'autoprefixer';
|
import autoprefixer from 'autoprefixer'
|
||||||
import cssnano from 'cssnano';
|
import cssnano from 'cssnano'
|
||||||
import ngAnnotate from 'gulp-ng-annotate';
|
|
||||||
import $if from 'gulp-if';
|
|
||||||
|
|
||||||
let env = process.env['NODE_ENV'] || 'production';
|
let env = process.env['NODE_ENV'] || 'production'
|
||||||
let isProduction = env === 'production';
|
let isProduction = env === 'production'
|
||||||
|
|
||||||
gulp.task('compile 3rdparty', () => {
|
gulp.task('compile 3rdparty', () => {
|
||||||
const files = [
|
const files = [
|
||||||
'./node_modules/jquery/dist/jquery.min.js',
|
'./node_modules/jquery/dist/jquery.min.js',
|
||||||
'./node_modules/angular/angular.min.js',
|
'./node_modules/angular/angular.min.js',
|
||||||
'./node_modules/angular-route/angular-route.min.js',
|
'./node_modules/angular-route/angular-route.min.js',
|
||||||
'./node_modules/angulartics/dist/angulartics.min.js',
|
'./node_modules/angulartics/dist/angulartics.min.js',
|
||||||
'./node_modules/angulartics-google-analytics/dist/angulartics-ga.min.js',
|
'./node_modules/angulartics-google-analytics/dist/angulartics-ga.min.js',
|
||||||
'./node_modules/spin.js/spin.js',
|
'./node_modules/spin.js/spin.js',
|
||||||
'./node_modules/angular-spinner/angular-spinner.min.js',
|
'./node_modules/angular-spinner/angular-spinner.min.js',
|
||||||
'./node_modules/socket.io-client/socket.io.js',
|
'./node_modules/socket.io-client/socket.io.js',
|
||||||
|
|
||||||
'./node_modules/babel-polyfill/dist/polyfill.min.js'
|
'./node_modules/babel-polyfill/dist/polyfill.min.js'
|
||||||
];
|
]
|
||||||
|
|
||||||
return gulp.src(files)
|
return gulp.src(files)
|
||||||
.pipe(concat('libs.js'))
|
.pipe(concat('libs.js'))
|
||||||
.pipe(uglify())
|
.pipe(uglify())
|
||||||
.pipe(gulp.dest('./public'));
|
.pipe(gulp.dest('./public'))
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('style', () => {
|
gulp.task('style', () => {
|
||||||
const processors = [
|
const processors = [
|
||||||
autoprefixer({
|
autoprefixer({
|
||||||
browsers: ['last 1 version']
|
browsers: ['last 1 version']
|
||||||
}),
|
}),
|
||||||
cssnano({
|
cssnano({
|
||||||
zindex: false
|
zindex: false
|
||||||
})
|
})
|
||||||
];
|
]
|
||||||
|
|
||||||
return gulp.src('./src/style/style.scss')
|
return gulp.src('./src/style/style.scss')
|
||||||
.pipe(sass())
|
.pipe(sass())
|
||||||
.pipe(postcss(processors))
|
.pipe(postcss(processors))
|
||||||
.pipe(concat('style.css'))
|
.pipe(concat('style.css'))
|
||||||
.pipe(gulp.dest('./public'));
|
.pipe(gulp.dest('./public'))
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('style-accessibility', () => {
|
gulp.task('style-accessibility', () => {
|
||||||
const processors = [
|
const processors = [
|
||||||
autoprefixer({
|
autoprefixer({
|
||||||
browsers: ['last 1 version']
|
browsers: ['last 1 version']
|
||||||
}),
|
}),
|
||||||
cssnano({
|
cssnano({
|
||||||
zindex: false
|
zindex: false
|
||||||
})
|
})
|
||||||
];
|
]
|
||||||
|
|
||||||
return gulp.src('./src/style-accessibility/style.scss')
|
return gulp.src('./src/style-accessibility/style.scss')
|
||||||
.pipe(sass())
|
.pipe(sass())
|
||||||
.pipe(postcss(processors))
|
.pipe(postcss(processors))
|
||||||
.pipe(concat('style-accessibility.css'))
|
.pipe(concat('style-accessibility.css'))
|
||||||
.pipe(gulp.dest('./public'));
|
.pipe(gulp.dest('./public'))
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('copy fonts', () => {
|
gulp.task('copy fonts', () => {
|
||||||
return gulp.src('./src/assets/fonts/*/*')
|
return gulp.src('./src/assets/fonts/*/*')
|
||||||
.pipe(gulp.dest('./public/fonts'));
|
.pipe(gulp.dest('./public/fonts'))
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('copy graphics', () => {
|
gulp.task('copy graphics', () => {
|
||||||
return gulp.src('./src/assets/graphics/*')
|
return gulp.src('./src/assets/graphics/*')
|
||||||
.pipe(gulp.dest('./public/graphics'));
|
.pipe(gulp.dest('./public/graphics'))
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('copy 3rdparty', () => {
|
gulp.task('copy 3rdparty', () => {
|
||||||
return gulp.src('./src/3rdparty/*')
|
return gulp.src('./src/3rdparty/*')
|
||||||
.pipe(gulp.dest('./public'));
|
.pipe(gulp.dest('./public'))
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('copy robots.txt', () => {
|
gulp.task('copy robots.txt', () => {
|
||||||
return gulp.src('./robots.txt')
|
return gulp.src('./robots.txt')
|
||||||
.pipe(gulp.dest('./public'));
|
.pipe(gulp.dest('./public'))
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('copy templates', () => {
|
gulp.task('copy templates', () => {
|
||||||
return gulp.src('./src/templates/**')
|
return gulp.src('./src/templates/**')
|
||||||
.pipe(gulp.dest('./out/templates'));
|
.pipe(gulp.dest('./out/templates'))
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('compile', () => {
|
gulp.task('compile', () => {
|
||||||
const doWatch = !isProduction;
|
const doWatch = !isProduction
|
||||||
const doSourceMaps = !isProduction;
|
const doSourceMaps = !isProduction
|
||||||
|
|
||||||
return gulp.src([
|
return gulp.src([
|
||||||
'./src/client/app.js'
|
'./src/client/app.js'
|
||||||
])
|
])
|
||||||
.pipe(named())
|
.pipe(named())
|
||||||
.pipe(webpack({
|
.pipe(webpack({
|
||||||
devtool: doSourceMaps ? 'inline-source-map' : null,
|
devtool: doSourceMaps ? 'inline-source-map' : null,
|
||||||
watch: doWatch,
|
watch: doWatch,
|
||||||
output: {
|
output: {
|
||||||
filename: '[name].js'
|
filename: '[name].js'
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
loaders: [
|
loaders: [
|
||||||
{test: /\.js$/, loader: 'babel'},
|
{test: /\.js$/, loader: 'babel'},
|
||||||
{test: /\.html$/, loader: 'raw!html-minify'}
|
{test: /\.html$/, loader: 'raw!html-minify'}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
'html-minify-loader': {
|
'html-minify-loader': {
|
||||||
empty: true,
|
empty: true,
|
||||||
cdata: true,
|
cdata: true,
|
||||||
comments: false,
|
comments: false,
|
||||||
dom: {
|
dom: {
|
||||||
lowerCaseAttributeNames: false
|
lowerCaseAttributeNames: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
// .pipe($if(isProduction, ngAnnotate()))
|
.pipe(gulp.dest('./public'))
|
||||||
// .pipe($if(isProduction, uglify()))
|
})
|
||||||
.pipe(gulp.dest('./public'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('imagemin', () => {
|
gulp.task('imagemin', () => {
|
||||||
return gulp.src('./src/assets/graphics/**/*')
|
return gulp.src('./src/assets/graphics/**/*')
|
||||||
.pipe(imageMin())
|
.pipe(imageMin())
|
||||||
.pipe(gulp.dest('./public/graphics'));
|
.pipe(gulp.dest('./public/graphics'))
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('production', () => {
|
gulp.task('production', () => {
|
||||||
isProduction = true;
|
isProduction = true
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('default', ['style', 'style-accessibility', 'compile']);
|
gulp.task('default', ['style', 'style-accessibility', 'compile'])
|
||||||
gulp.task('copy', ['copy templates', 'copy fonts', 'copy graphics', 'copy 3rdparty', 'copy robots.txt']);
|
gulp.task('copy', ['copy templates', 'copy fonts', 'copy graphics', 'copy 3rdparty', 'copy robots.txt'])
|
||||||
gulp.task('deploy', ['default', 'copy', 'compile 3rdparty', 'imagemin']);
|
gulp.task('deploy', ['default', 'copy', 'compile 3rdparty', 'imagemin'])
|
||||||
gulp.task('compile production', ['production', 'compile']);
|
gulp.task('compile production', ['production', 'compile'])
|
||||||
Reference in new issue
Block a user