How to require jquery file with webpack should I have to install from npm, or can I just require the file download from jquery website?
directory
app/
./assets/javascripts/article/create/base.js
./assets/javascripts/lib/jquery-1.11.1.min.js
webpack.config.js
base.js error
require('../../../lib/jquery-1.11.1.min.js');
var Content = function() {
};
module.exports = Content;
webpack.config.js
module.exports = {
entry: {
'ArticleCreate':['./assets/javascripts/Article/Create/Base.js']
},
output: {
path: './assets/javascripts/bundle/',
filename: '[name].js'
}
};
Have you tried:
module.exports = {
...
resolve: {
alias: {
jquery: "jquery/src/jquery"
}
}
};
There is a related answer which shows all options of importing jQuery here: Managing jQuery plugin dependency in webpack
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With