Skip to content

Instantly share code, notes, and snippets.

@preslavrachev
Last active July 11, 2017 15:48
Show Gist options
  • Save preslavrachev/44263bcbbb6395b7821a to your computer and use it in GitHub Desktop.
Save preslavrachev/44263bcbbb6395b7821a to your computer and use it in GitHub Desktop.
Integrating browserify into an Ionic project
var customModule = require('./custom-module');
var app = angular.module('myApp', ['ionic']);
...
...
var rename = require('gulp-rename');
var browserify = require('gulp-browserify');
var paths = {
...
js: ['./www/js/**/*.js']
};
gulp.task('default', ['sass','browserify']);
gulp.task('browserify', function() {
// Single entry point to browserify
gulp.src('www/js/app.js')
.pipe(browserify({
insertGlobals : true,
debug : false
}))
.pipe(rename(function(path) {
path.basename += ".dist";
}))
.pipe(gulp.dest('www/js'))
});
gulp.task('watch', function() {
...
gulp.watch(paths.js, ['browserify']);
});
...
<!--- <script src="js/app.js"></script> -->
<!-- Use the generated app.dist.js, instead of app.js -->
<script src="js/app.dist.js"></script>
{
...
"gulpStartupTasks": ["browserify", "sass", "watch"]
}
{
"dependencies": {
...
"gulp-browserify": "^0.5.0",
"base64-js": "^0.0.7", // caused an error without it
"ieee754": "^1.1.4" // caused an error without it
...
"gulp-rename": "^1.2.0", //wasn't included among the base gulp plugins
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment