forked from bingqichen/antd-message
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
61 lines (56 loc) · 1.45 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const gulp = require('gulp');
const replace = require('gulp-replace');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const less = require('gulp-less');
const postcss = require('gulp-postcss');
const autoprefixer = require('autoprefixer');
const clean = require('gulp-clean-css');
const sourcemaps = require('gulp-sourcemaps');
gulp.task('static', () => (
gulp.src([
'src/**/*.*',
'!src/**/*.js',
'!src/**/*.less'
])
.pipe(gulp.dest('dist'))
));
gulp.task('js', () => (
gulp.src('src/**/*.js')
.pipe(sourcemaps.init())
.pipe(babel({
babelrc: false,
presets: ['es2015', 'react', 'stage-0'],
plugins: [
'transform-runtime',
[
'babel-plugin-root-import',
[
{
rootPathPrefix: '~',
rootPathSuffix: 'src'
}
]
]
]
}))
.pipe(uglify())
.pipe(replace(/(.*?require.+?\.)less|sass|scss|stylus(.*?)/gm, '$1css$2'))
.pipe(sourcemaps.write('', {
mapFile: mapFilePath => mapFilePath.replace('.js.map', '.map')
}))
.pipe(gulp.dest('dist'))
));
gulp.task('less', () => (
gulp.src('src/**/*.less')
.pipe(less())
.pipe(postcss([
autoprefixer({ browsers: ['> 1%', 'ie >= 8'] })
]))
.pipe(clean())
.pipe(gulp.dest('dist'))
));
gulp.task('default', ['static', 'js', 'less']);
gulp.task('watch', () => (
gulp.watch('src/**/*.*', ['static', 'js', 'less'])
));