Skip to content

Commit 6e80143

Browse files
committed
Add clean task for all chapters
1 parent 060799c commit 6e80143

File tree

7 files changed

+84
-33
lines changed

7 files changed

+84
-33
lines changed

tutorial/10-immutable-redux-improvements/gulpfile.babel.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import gulp from 'gulp';
44
import babel from 'gulp-babel';
55
import eslint from 'gulp-eslint';
6+
import del from 'del';
67
import webpack from 'webpack-stream';
78
import webpackConfig from './webpack.config.babel';
89

@@ -11,16 +12,13 @@ const paths = {
1112
serverSrcJs: 'src/server/**/*.js?(x)',
1213
sharedSrcJs: 'src/shared/**/*.js?(x)',
1314
clientEntryPoint: 'src/client/app.jsx',
15+
clientBundle: 'dist/client-bundle.js?(.map)',
1416
gulpFile: 'gulpfile.babel.js',
1517
webpackFile: 'webpack.config.babel.js',
18+
libDir: 'lib',
19+
distDir: 'dist',
1620
};
1721

18-
gulp.task('build', ['lint'], () =>
19-
gulp.src(paths.allSrcJs)
20-
.pipe(babel())
21-
.pipe(gulp.dest('lib'))
22-
);
23-
2422
gulp.task('lint', () =>
2523
gulp.src([
2624
paths.allSrcJs,
@@ -32,10 +30,21 @@ gulp.task('lint', () =>
3230
.pipe(eslint.failAfterError())
3331
);
3432

35-
gulp.task('main', ['lint'], () =>
33+
gulp.task('clean', () => del([
34+
paths.libDir,
35+
paths.clientBundle,
36+
]));
37+
38+
gulp.task('build', ['lint', 'clean'], () =>
39+
gulp.src(paths.allSrcJs)
40+
.pipe(babel())
41+
.pipe(gulp.dest(paths.libDir))
42+
);
43+
44+
gulp.task('main', ['lint', 'clean'], () =>
3645
gulp.src(paths.clientEntryPoint)
3746
.pipe(webpack(webpackConfig))
38-
.pipe(gulp.dest('dist'))
47+
.pipe(gulp.dest(paths.distDir))
3948
);
4049

4150
gulp.task('watch', () => {

tutorial/11-testing-mocha-chai-sinon/gulpfile.babel.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import gulp from 'gulp';
44
import babel from 'gulp-babel';
55
import eslint from 'gulp-eslint';
66
import mocha from 'gulp-mocha';
7+
import del from 'del';
78
import webpack from 'webpack-stream';
89
import webpackConfig from './webpack.config.babel';
910

@@ -13,8 +14,11 @@ const paths = {
1314
sharedSrcJs: 'src/shared/**/*.js?(x)',
1415
allLibTests: 'lib/test/**/*.js',
1516
clientEntryPoint: 'src/client/app.jsx',
17+
clientBundle: 'dist/client-bundle.js?(.map)',
1618
gulpFile: 'gulpfile.babel.js',
1719
webpackFile: 'webpack.config.babel.js',
20+
libDir: 'lib',
21+
distDir: 'dist',
1822
};
1923

2024
gulp.task('lint', () =>
@@ -28,10 +32,15 @@ gulp.task('lint', () =>
2832
.pipe(eslint.failAfterError())
2933
);
3034

31-
gulp.task('build', ['lint'], () =>
35+
gulp.task('clean', () => del([
36+
paths.libDir,
37+
paths.clientBundle,
38+
]));
39+
40+
gulp.task('build', ['lint', 'clean'], () =>
3241
gulp.src(paths.allSrcJs)
3342
.pipe(babel())
34-
.pipe(gulp.dest('lib'))
43+
.pipe(gulp.dest(paths.libDir))
3544
);
3645

3746
gulp.task('test', ['build'], () =>
@@ -42,7 +51,7 @@ gulp.task('test', ['build'], () =>
4251
gulp.task('main', ['test'], () =>
4352
gulp.src(paths.clientEntryPoint)
4453
.pipe(webpack(webpackConfig))
45-
.pipe(gulp.dest('dist'))
54+
.pipe(gulp.dest(paths.distDir))
4655
);
4756

4857
gulp.task('watch', () => {

tutorial/12-flow/gulpfile.babel.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
import gulp from 'gulp';
44
import babel from 'gulp-babel';
55
import eslint from 'gulp-eslint';
6-
import mocha from 'gulp-mocha';
76
import flow from 'gulp-flowtype';
7+
import mocha from 'gulp-mocha';
8+
import del from 'del';
89
import webpack from 'webpack-stream';
910
import webpackConfig from './webpack.config.babel';
1011

@@ -14,8 +15,11 @@ const paths = {
1415
sharedSrcJs: 'src/shared/**/*.js?(x)',
1516
allLibTests: 'lib/test/**/*.js',
1617
clientEntryPoint: 'src/client/app.jsx',
18+
clientBundle: 'dist/client-bundle.js?(.map)',
1719
gulpFile: 'gulpfile.babel.js',
1820
webpackFile: 'webpack.config.babel.js',
21+
libDir: 'lib',
22+
distDir: 'dist',
1923
};
2024

2125
gulp.task('lint', () =>
@@ -30,10 +34,15 @@ gulp.task('lint', () =>
3034
.pipe(flow({ abort: true }))
3135
);
3236

33-
gulp.task('build', ['lint'], () =>
37+
gulp.task('clean', () => del([
38+
paths.libDir,
39+
paths.clientBundle,
40+
]));
41+
42+
gulp.task('build', ['lint', 'clean'], () =>
3443
gulp.src(paths.allSrcJs)
3544
.pipe(babel())
36-
.pipe(gulp.dest('lib'))
45+
.pipe(gulp.dest(paths.libDir))
3746
);
3847

3948
gulp.task('test', ['build'], () =>
@@ -44,7 +53,7 @@ gulp.task('test', ['build'], () =>
4453
gulp.task('main', ['test'], () =>
4554
gulp.src(paths.clientEntryPoint)
4655
.pipe(webpack(webpackConfig))
47-
.pipe(gulp.dest('dist'))
56+
.pipe(gulp.dest(paths.distDir))
4857
);
4958

5059
gulp.task('watch', () => {

tutorial/7-client-webpack/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ One last thing: unlike our `lib` folder, the `dist/client-bundle.js` and `dist/c
180180
- Add `clientBundle: 'dist/client-bundle.js?(.map)'` to our `paths` configuration, and tweak the `clean` task like so:
181181

182182
```javascript
183-
gulp.task('clean', () => del([paths.libDir, paths.clientBundle]));
183+
gulp.task('clean', () => del([
184+
paths.libDir,
185+
paths.clientBundle,
186+
]));
184187
```
185188

186189
- Add `/dist/client-bundle.js*` to your `.gitignore` file:

tutorial/7-client-webpack/gulpfile.babel.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ gulp.task('lint', () =>
3030
.pipe(eslint.failAfterError())
3131
);
3232

33-
gulp.task('clean', () => del([paths.libDir, paths.clientBundle]));
33+
gulp.task('clean', () => del([
34+
paths.libDir,
35+
paths.clientBundle,
36+
]));
3437

3538
gulp.task('build', ['lint', 'clean'], () =>
3639
gulp.src(paths.allSrcJs)

tutorial/8-react/gulpfile.babel.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import gulp from 'gulp';
44
import babel from 'gulp-babel';
55
import eslint from 'gulp-eslint';
6+
import del from 'del';
67
import webpack from 'webpack-stream';
78
import webpackConfig from './webpack.config.babel';
89

@@ -11,16 +12,13 @@ const paths = {
1112
serverSrcJs: 'src/server/**/*.js?(x)',
1213
sharedSrcJs: 'src/shared/**/*.js?(x)',
1314
clientEntryPoint: 'src/client/app.jsx',
15+
clientBundle: 'dist/client-bundle.js?(.map)',
1416
gulpFile: 'gulpfile.babel.js',
1517
webpackFile: 'webpack.config.babel.js',
18+
libDir: 'lib',
19+
distDir: 'dist',
1620
};
1721

18-
gulp.task('build', ['lint'], () =>
19-
gulp.src(paths.allSrcJs)
20-
.pipe(babel())
21-
.pipe(gulp.dest('lib'))
22-
);
23-
2422
gulp.task('lint', () =>
2523
gulp.src([
2624
paths.allSrcJs,
@@ -32,10 +30,21 @@ gulp.task('lint', () =>
3230
.pipe(eslint.failAfterError())
3331
);
3432

35-
gulp.task('main', ['lint'], () =>
33+
gulp.task('clean', () => del([
34+
paths.libDir,
35+
paths.clientBundle,
36+
]));
37+
38+
gulp.task('build', ['lint', 'clean'], () =>
39+
gulp.src(paths.allSrcJs)
40+
.pipe(babel())
41+
.pipe(gulp.dest(paths.libDir))
42+
);
43+
44+
gulp.task('main', ['lint', 'clean'], () =>
3645
gulp.src(paths.clientEntryPoint)
3746
.pipe(webpack(webpackConfig))
38-
.pipe(gulp.dest('dist'))
47+
.pipe(gulp.dest(paths.distDir))
3948
);
4049

4150
gulp.task('watch', () => {

tutorial/9-redux/gulpfile.babel.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import gulp from 'gulp';
44
import babel from 'gulp-babel';
55
import eslint from 'gulp-eslint';
6+
import del from 'del';
67
import webpack from 'webpack-stream';
78
import webpackConfig from './webpack.config.babel';
89

@@ -11,16 +12,13 @@ const paths = {
1112
serverSrcJs: 'src/server/**/*.js?(x)',
1213
sharedSrcJs: 'src/shared/**/*.js?(x)',
1314
clientEntryPoint: 'src/client/app.jsx',
15+
clientBundle: 'dist/client-bundle.js?(.map)',
1416
gulpFile: 'gulpfile.babel.js',
1517
webpackFile: 'webpack.config.babel.js',
18+
libDir: 'lib',
19+
distDir: 'dist',
1620
};
1721

18-
gulp.task('build', ['lint'], () =>
19-
gulp.src(paths.allSrcJs)
20-
.pipe(babel())
21-
.pipe(gulp.dest('lib'))
22-
);
23-
2422
gulp.task('lint', () =>
2523
gulp.src([
2624
paths.allSrcJs,
@@ -32,10 +30,21 @@ gulp.task('lint', () =>
3230
.pipe(eslint.failAfterError())
3331
);
3432

35-
gulp.task('main', ['lint'], () =>
33+
gulp.task('clean', () => del([
34+
paths.libDir,
35+
paths.clientBundle,
36+
]));
37+
38+
gulp.task('build', ['lint', 'clean'], () =>
39+
gulp.src(paths.allSrcJs)
40+
.pipe(babel())
41+
.pipe(gulp.dest(paths.libDir))
42+
);
43+
44+
gulp.task('main', ['lint', 'clean'], () =>
3645
gulp.src(paths.clientEntryPoint)
3746
.pipe(webpack(webpackConfig))
38-
.pipe(gulp.dest('dist'))
47+
.pipe(gulp.dest(paths.distDir))
3948
);
4049

4150
gulp.task('watch', () => {

0 commit comments

Comments
 (0)