-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from webpack/d3viant0ne-BabelBuild
chore(build): Reworks babel build
- Loading branch information
Showing
8 changed files
with
110 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
node_modules | ||
coverage | ||
dist | ||
lib |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
'use strict' // eslint-disable-line strict | ||
|
||
const gulp = require('gulp') | ||
const del = require('del') | ||
const util = require('gulp-util') | ||
const eslint = require('gulp-eslint') | ||
const babel = require('gulp-babel') | ||
|
||
gulp.task('clean', function(done) { | ||
del([ | ||
'lib/**/*', | ||
]) | ||
done() | ||
}) | ||
|
||
/** | ||
* Lints all the JavaScript in the project. | ||
* Ignores transpiled code & node_modules. | ||
*/ | ||
gulp.task('lint', function(done) { | ||
gulp.src(['**/*.js', '!node_modules/**', '!lib/**']) | ||
.pipe(eslint()) | ||
.pipe(eslint.format()) | ||
.pipe(eslint.failAfterError()) | ||
done() | ||
}) | ||
|
||
/** | ||
* Transpiles with Babel based on defined presets. | ||
*/ | ||
gulp.task('build', function(done) { | ||
gulp.src('src/**/*.js') | ||
.pipe(babel()) | ||
.pipe(gulp.dest('lib')) | ||
done() | ||
}) | ||
|
||
/** | ||
* Watches for changes in the src directory. | ||
* "on change" transpiles incrementally. | ||
* "on unlink" removes the transpiled version of the deleted file. | ||
*/ | ||
gulp.task('watch', function() { | ||
gulp.watch('src/**/*.js') | ||
.on('change', function(path) { | ||
gulp.src(path) | ||
.pipe(babel()) | ||
.pipe(gulp.dest('lib')) | ||
util.log(`File "${path}" rebuilt`) | ||
}) | ||
.on('unlink', function(path) { | ||
util.log(`File "${path}" removed`) | ||
let filePathFromSrc = path.relative(path.resolve('src')) | ||
let destFilePath = path.resolve('build', filePathFromSrc) | ||
|
||
del.sync(destFilePath) | ||
}) | ||
}) | ||
|
||
/** | ||
* Entrypoint for running watch. | ||
*/ | ||
gulp.task('build.watch', gulp.series('build', 'watch', function(done) { | ||
done() | ||
})) | ||
|
||
gulp.task('default', gulp.series('clean', 'lint', 'build', function(done) { | ||
done() | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* | ||
MIT License http://www.opensource.org/licenses/mit-license.php | ||
Author Tobias Koppers @sokra | ||
*/ | ||
module.exports = require('./lib/karma-webpack') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.