1 |
|
2 |
|
3 | var pkg = require('./package.json');
|
4 | // https://github.com/gulpjs/gulp/blob/master/docs/README.md
|
5 | var gulp = require('gulp');
|
6 | // http://webpack.github.io/docs/
|
7 | var webpack = require('webpack');
|
8 | // https://github.com/shama/webpack-stream
|
9 | var webpackStream = require('webpack-stream');
|
10 |
|
11 |
|
12 | gulp.task(
|
13 | pkg.name + '/build',
|
14 | function() {
|
15 | return gulp
|
16 | .src('./src/index.js')
|
17 | .pipe(webpackStream({
|
18 | module: {
|
19 | loaders: [
|
20 | // https://github.com/babel/babel-loader
|
21 | {test: /\.js$/, loader: 'babel'},
|
22 | // https://github.com/webpack/json-loader
|
23 | {test: /\.json$/, loader: 'json'},
|
24 | // https://github.com/webpack/html-loader
|
25 | {test: /\.html$/, loader: 'html'}
|
26 | ]
|
27 | },
|
28 | plugins: [
|
29 | // http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
|
30 | new webpack.optimize.UglifyJsPlugin({
|
31 | compress: {
|
32 | warnings: false
|
33 | }
|
34 | }),
|
35 | // http://webpack.github.io/docs/list-of-plugins.html#bannerplugin
|
36 | new webpack.BannerPlugin(
|
37 | '/*\n' +
|
38 | ' ' + pkg.name + ' v' + pkg.version + '\n' +
|
39 | ' ' + pkg.homepage + '\n' +
|
40 | '*/\n'
|
41 | , {
|
42 | entryOnly: true,
|
43 | raw: true
|
44 | })
|
45 | ],
|
46 | devtool: 'source-map',
|
47 | debug: true,
|
48 | output: {
|
49 | library: pkg.name,
|
50 | libraryTarget: 'umd',
|
51 | filename: pkg.name + '.min.js'
|
52 | }
|
53 | }))
|
54 | .pipe(gulp.dest('./dist'));
|
55 | }
|
56 | );
|
57 |
|
58 |
|
59 | gulp.task(
|
60 | pkg.name + '/watch', function() {
|
61 | return gulp
|
62 | .watch(
|
63 | [
|
64 | './src/**/*.js',
|
65 | './src/**/*.json',
|
66 | './src/**/*.html'
|
67 | ],
|
68 | [
|
69 | pkg.name + '/build'
|
70 | ]
|
71 | );
|
72 | }
|
73 | );
|