-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
executable file
·85 lines (75 loc) · 2.42 KB
/
Copy pathgulpfile.babel.js
File metadata and controls
executable file
·85 lines (75 loc) · 2.42 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import gulpRaw from 'gulp';
import gulpHelp from 'gulp-help';
import plumber from 'gulp-plumber';
import sass from 'gulp-sass';
import header from 'gulp-header';
import fecha from 'fecha';
import webpack from 'webpack';
import webpackStream from 'webpack-stream';
let gulp = gulpHelp(gulpRaw);
var config = {
sass: {
from: 'src/sass/app.scss',
to: 'min',
watch: 'src/sass/*.scss'
},
jsx: {
from: 'src/jsx/app.jsx',
to: 'min',
watch: 'src/jsx/*.jsx'
}
};
var banner = '/*! Acme PHP | (c) Titouan Galopin | Build ${date} */\n';
gulp.task('sass:dev', () =>
gulp.src(config.sass.from)
.pipe(plumber())
.pipe(sass({ outputStyle: 'expanded' }))
.pipe(gulp.dest(config.sass.to))
);
gulp.task('sass:prod', () =>
gulp.src(config.sass.from)
.pipe(plumber())
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(header(banner, { date: fecha.format(new Date(), 'YYYYMMDD') }))
.pipe(gulp.dest(config.sass.to))
);
gulp.task('sass:watch', ['sass:dev'], () =>
gulp.watch([ config.sass.watch ], ['sass:dev'])
);
gulp.task('jsx:dev', () =>
gulp.src(config.jsx.from)
.pipe(plumber())
.pipe(webpackStream({
output: {
libraryType: 'var',
library: 'App',
filename: 'app.js'
},
module: { loaders: [ { test: /\.jsx?$/, loader: 'babel' } ] }
}))
.pipe(gulp.dest(config.jsx.to))
);
gulp.task('jsx:prod', () =>
gulp.src(config.jsx.from)
.pipe(plumber())
.pipe(webpackStream({
output: {
libraryType: 'var',
library: 'App',
filename: 'app.js'
},
module: { loaders: [ { test: /\.jsx?$/, loader: 'babel' } ] },
plugins: [
new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': JSON.stringify('production') } }),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false }, test: /\.js($|\?)/i })
]
}))
.pipe(header(banner, { date: fecha.format(new Date(), 'YYYYMMDD') }))
.pipe(gulp.dest(config.jsx.to))
);
gulp.task('jsx:watch', ['jsx:dev'], () =>
gulp.watch([ config.jsx.watch ], ['jsx:dev'])
);
gulp.task('prod', ['sass:prod', 'jsx:prod']);
gulp.task('default', ['sass:watch', 'jsx:watch']);