简体   繁体   中英

Error importing JQuery plugin with Webpack 2.2.1

I've a simple Symfony/Webpack project that runs great with webpack 2.2.0. But since updating to 2.2.1, the front side breaks when running project with webpack-dev-server.

You can clone example project : git@gitlab.com:gaea44/symfony-webpack-221.git

Here is how I configured webpack :

├── app
|   └── Resources
|       └── assets
|           └── src
|               └── app.js
|── other symfony files
|── package.json
|── webpack.dev.js
└── webpack.config.js

Here is my webpack.config.js :

context: path.resolve(__dirname, './app/Resources/assets/src'),

entry  : {
    app: './app.js',
},

output : {
    path         : path.resolve(__dirname, './web/build'),
    filename     : '[name].js',
    chunkFilename: '[name].bundle.js',
    publicPath   : 'http://localhost:8090/assets/',
},

I use babel with es-2015

{
    test: /\.js$/,
    use : [{
      loader : 'babel-loader',
      options: {
        presets    : ['es2015'],
        retainLines: true,
      }
    }],
},

Other Webpack plugin I use are : CommonsChunkPlugin, HotModuleReplacementPlugin, UglifyJsPlugin and DefinePlugin.

I symply import a jQuery plugin inside my app.js file :

// Jquery
import 'expose-loader?$!expose-loader?jQuery!jquery';

// Boostrap
import 'bootstrap-sass';

// Other vendor
import 'bootstrap-fileinput';
import 'bootstrap-fileinput/js/locales/fr';

$('[type=file]').fileinput();

And the error I get :

在此输入图像描述

Plugins works fine with webpack 2.2.0 (you can test if with webpack220 branch on the example project)

Thanks for any help

在bootstrap-fileinput: window.$ = window.jQuery = require('jquery');之前添加行window.$ = window.jQuery = require('jquery');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM