Skip to content

Instantly share code, notes, and snippets.

@justinmetros
Last active August 3, 2017 01:18
Show Gist options
  • Save justinmetros/483aeea74a7ca68802a2159898bf01f1 to your computer and use it in GitHub Desktop.
Save justinmetros/483aeea74a7ca68802a2159898bf01f1 to your computer and use it in GitHub Desktop.
Rollup Config in Gulp - jQuery External Issue
// ...
// Build JS with Rollup
// ---------------------------------------
gulp.task('js', ['lint-js'], () => {
console.log('*** Compiling JS ***'.green);
return rollup.rollup({
entry: "./src/js/theme.js",
plugins: [
resolve({
jsnext: true,
main: true,
browser: true
}),
cjs({
include: [
'node_modules/**',
'src/js/vendor/**'
]
}),
amd(),
legacy({}),
inject({
include: '**/*.js',
exclude: 'node_modules/**',
jQuery: 'jquery',
$: 'jquery',
jquery: 'jquery'
}),
babel({
exclude: 'node_modules/**'
}),
],
external: ['jquery', 'jQuery']
})
.then(function (bundle) {
bundle.write({
format: 'iife',
dest: "./theme/assets/theme.js",
globals: {
jquery: '$'
},
});
})
});
//...
@justinmetros
Copy link
Author

justinmetros commented Aug 3, 2017

Goal:

To include a 3rd party lib from npm that requires jquery but keep that dependency external and global.

I am linking to jquery from CDN and would like to keep it that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment