forked from babel/babel-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
59 lines (57 loc) · 1.49 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
var gulp = require('gulp');
var rename = require('gulp-rename');
var webpack = require('webpack');
var webpackStream = require('webpack-stream');
var uglify = require('gulp-uglify');
gulp.task('default', ['build']);
gulp.task('build', function() {
return gulp.src('src/index.js')
.pipe(webpackStream({
module: {
loaders: [
{
exclude: /node_modules/,
test: /\.js$/,
loader: 'babel',
query: {
presets: ['es2015', 'stage-0']
}
},
{
test: /\.json$/,
loader: 'json'
}
]
},
node: {
// Mock Node.js modules that Babel require()s but that we don't
// particularly care about.
fs: 'empty',
module: 'empty',
net: 'empty'
},
output: {
filename: 'babel.js',
library: 'Babel',
libraryTarget: 'umd'
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
// Use browser version of visionmedia-debug
new webpack.NormalModuleReplacementPlugin(
/debug\/node/,
'debug/browser'
),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin()
]
}))
// Output unminified version
.pipe(gulp.dest('.'))
// Output minified version
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('.'));
});