-
Notifications
You must be signed in to change notification settings - Fork 374
/
gulpfile.js
59 lines (54 loc) · 1.36 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
const Webpack = require('webpack')
const gulp = require('gulp')
const webpack = require('gulp-webpack')
const cssnano = require('gulp-cssnano')
const rename = require('gulp-rename')
const sass = require('gulp-sass')
const del = require('del')
const run = require('run-sequence')
gulp.task('clean', () => del(['./dist']))
const webpackConfig = minimize => ({
output: {
filename: minimize ? 'notie.min.js' : 'notie.js',
library: 'notie',
libraryTarget: 'umd'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: ['babel-loader']
}
]
},
plugins: minimize
? [
new Webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
mangle: true,
sourcemap: false
})
]
: []
})
gulp.task('script', () => {
gulp.src('./src/notie.js')
.pipe(webpack(webpackConfig(false), Webpack))
.pipe(gulp.dest('./dist'))
.pipe(webpack(webpackConfig(true), Webpack))
.pipe(gulp.dest('./dist'))
})
gulp.task('style', () => {
gulp.src(['./src/notie.scss'])
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./dist'))
.pipe(cssnano())
.pipe(rename('notie.min.css'))
.pipe(gulp.dest('./dist'))
})
gulp.task('default', ['clean'], () => {
run('script', 'style')
gulp.watch('./src/notie.scss', ['style'])
gulp.watch('./src/notie.js', ['script'])
})