My current tasks on the gulpfile.js for my frontend app involve a serve
task that handles the following:
- Processing less files
- Bundling all javascripts into dist/bundle.js
- Uglifying dist/bundle.js
However, this setup made local debugging difficult. To address this issue, I introduced a new task called serve:debug
, initially excluding the uglification of dist/bundle.js
.
gulp.task('serve:debug', ['less', 'bundle', 'watch'], function () {
runServer('http://localhost/app/login.html')
});
This enables me to debug the code easily with human-readable JavaScript. But, since all files are still bundled together and the application explicitly imports dist/bundle.js
in index.html:
<script src="dist/bundle.js"></script>
If I remove the bundle
task from serve:debug
, the application will no longer be able to reach dist/bundle.js
.
Question: What are some best practices when it comes to importing JavaScript files in such scenarios?