How can I only compile changed/new files?
See original GitHub issueThis script compiles all .js
files from the ./src
js folder to es6. These are saved individually! The path remains the same, only ./src/js
becomes ./build/js
. This is important! I do not want to have bundle.js
.
When I call this task, every time all .js
files are compiled. However, only currently changed files should be compiled. But how? How can I add this into my task?
package.json (part of it):
"paths": {
"src": {
"base": "./src/",
"css": "./src/css/",
"json": "./src/json/",
"js": "./src/js/",
"scss": "./src/scss/"
},
"dist": {
"base": "./public/",
"css": "./public/css/",
"js": "./public/js/",
"material": "./public/js/@material/"
},
"build": {
"base": "./build/",
"css": "./build/css/",
"js": "./build/js/",
"html": "./build/html/"
}
},
"globs": {
"babelJs": [
"./src/js/**/*.js"
]
}
gulpfile.js:
gulp.task('js-babel', function() {
console.log($.chalk.yellow.bold('--> Transpiling Javascript via Browserify & Babelify...'));
let files = $.glob.sync(''+pkg.globs.babelJs+'');
// map them to streams
let tasks = files.map(function(entry) {
return $.browserify({ entries: [entry] })
.transform('babelify')
.bundle()
.pipe($.vinylSourceStream(entry))
.pipe($.flatten()) // Important!!!!
.pipe(gulp.dest(pkg.paths.build.js))
.pipe($.size({gzip: true, showFiles: true}));
});
// merge
return $.eventStream.merge.apply(null, tasks);
});
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
How do I make Makefile to recompile only changed files?
I have been struggling a bit to get make to compile only the files that have been edited. However I didn't have much...
Read more >how to build with make so that only the changed files get build
First, you have to remove the clean dependency from your JYOTI target. Otherwise, everything is always built from scratch.
Read more >Avoiding Compilation (GNU make)
Recompile the source files that need compilation for reasons independent of the particular header file, with ' make -o headerfile '. If several...
Read more >How to create a Makefile that will build only the files that have ...
How can I create a Makefile to recompile only the changed .cpp files? The easiest way is to skip the header files in...
Read more >compiling only the changed files in the project - Keil forum
Press the 'Build Target' button instead of the 'Rebuild all Target files' button. Note that using the SRC directive forces files to be ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
browserify looks like the wrong tool to use from that code snippet. You should not use browserify on every source file. You should only call it on your entry point(s) and generate a single bundle (or multiple bundles if they get too big). If you want to compile files with babel, and not create browser bundles that include all dependencies, use gulp-babel instead of browserify. Then use gulp-newer to only compile changed files.
watchify can be used during development to automatically and quickly rebuild the bundle when files change.
@goto-bus-stop - thanks a lot! I will give this a try 😃