-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
52 lines (41 loc) · 1.31 KB
/
gulpfile.babel.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
import gulp from 'gulp';
import webpack from 'webpack-stream';
import rimraf from 'rimraf';
import preprocess from 'gulp-preprocess';
const webpackConfig = require('./webpack.config');
const devConfig = {
context: {
ENVIRONMENT: 'development',
API_HOST: 'http://localhost:3000',
FRONTEND_HOST: 'http://localhost:5000',
},
};
const prodConfig = {
context: {
ENVIRONMENT: 'production',
API_HOST: 'https://notist.herokuapp.com',
FRONTEND_HOST: 'https://notist.io',
},
};
gulp.task('clean', cb =>
rimraf('dist/', cb));
gulp.task('image', ['clean'], () =>
gulp.src('./src/images/*').pipe(gulp.dest('./dist')));
gulp.task('manifest', ['clean'], () =>
gulp.src('manifest.json').pipe(gulp.dest('./dist')));
gulp.task('lib', ['manifest', 'image'], () =>
gulp.src('./src/lib/**/*.{js,css}')
.pipe(gulp.dest('dist/lib')));
const build = (config) => {
gulp.src('src/content.js')
.pipe(webpack(webpackConfig))
.pipe(preprocess(config))
.pipe(gulp.dest('./dist'));
gulp.src('src/background.js')
.pipe(webpack(webpackConfig))
.pipe(preprocess(config))
.pipe(gulp.dest('./dist'));
};
gulp.task('dev', ['lib'], () => build(devConfig));
gulp.task('prod', ['lib'], () => build(prodConfig));
gulp.task('watch', ['dev'], () => gulp.watch('./src/**/*', ['dev']));