Answer the question
In order to leave comments, you need to log in
How to correctly connect jquery to the assembly?
webpack.config.js:
'use strict';
const NODE_ENV = process.env.NODE_ENV || 'dev';
const webpack = require('webpack');
module.exports = {
entry: './js/main',
output: {
filename: './js/app.js'
},
// watch: NODE_ENV == 'dev',
plugins: [
new webpack.EnvironmentPlugin('NODE_ENV')
],
resolve: {
alias: {
jquery: "jquery/src/jquery"
}
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel?presets[]=es2015'
}
]
}
};
Answer the question
In order to leave comments, you need to log in
I hope app.js has require('jquery') :-)
In plugins , you can try to add ProvidePlugin , specifying jQuery alternative names , so that webpack treats these names as jQuery :
plugins: [
new webpack.EnvironmentPlugin('NODE_ENV'),
new webpack.ProvidePlugin({
'$': 'jquery',
'jQuery': 'jquery'
})
]
resolve: {
modulesDirectories: ['./', 'node_modules'],
// ...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question