Last active
August 3, 2017 01:18
-
-
Save justinmetros/483aeea74a7ca68802a2159898bf01f1 to your computer and use it in GitHub Desktop.
Rollup Config in Gulp - jQuery External Issue
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
// ... | |
// 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: '$' | |
}, | |
}); | |
}) | |
}); | |
//... |
Author
justinmetros
commented
Aug 3, 2017
•
// slick.js from node_modules
//...
/* global window, document, define, jQuery, setInterval, clearInterval */
(function(factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof exports !== 'undefined') {
module.exports = factory(require('jquery')); // <--- F*ck this line in particular
} else {
factory(jQuery);
}
}(function($) {
'use strict';
var Slick = window.Slick || {};
Slick = (function() {
// .....
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