管理webpack中的jQuery插件依赖关系
var webpack = require('webpack');var bower_dir = __dirname + '/bower_components';var node_dir = __dirname + '/node_modules';
var lib_dir = __dirname + '/public/js/libs';var config = {
addVendor: function (name, path) {
this.resolve.alias[name] = path;
this.module.noParse.push(new RegExp(path));
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jquery: "jQuery",
"window.jQuery": "jquery"
}),
new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js', Infinity)
],
entry: {
app: ['./public/js/main.js'],
vendors: ['react','jquery']
},
resolve: {
alias: {
'jquery': node_dir + '/jquery/dist/jquery.js',
'jquery.elastic': lib_dir + '/jquery.elastic.source.js'
}
},
output: {
path: './public/js',
filename: 'bundle.js'
},
module: {
loaders: [
{ test: /\.js$/, loader: 'jsx-loader' },
{ test: /\.jquery.elastic.js$/, loader: 'imports-loader' }
]
}}
未定义的参考错误:jQuery未定义
要求未定义‘
var jQuery = require("jquery")define([
'jquery',
'react',
'../../common-functions',
'../../libs/jquery.elastic.source'],function($,React,commonFunctions){
$("#myInput").elastic() //It works});小怪兽爱吃肉
子衿沉夜
holdtom
相关分类