2016-08-12 4 views
0

jQuery 플러그인 (jquery.jplayer.js)을 포함하는 곳에 문제가 있으며 webpack은 해당 파일의 종속성을이 파일 (이 경우 jQuery)로로드합니다. jQuery를 CDN으로 제공하고 싶습니다. jQuery를 로컬로로드하지 않으려 고합니다. 나는이 코드 줄인 define(['jquery'], factory); // jQuery Switch으로 좁혔다.webpack 종속성을로드하지 않습니다.

.js 파일에있는 종속성을 포함하지 않도록 webpack에 어떻게 지시 할 수 있습니까?

var debug = process.env.NODE_ENV !== "production"; 
var webpack = require("webpack"); 
var path = require("path"); 

module.exports = { 
    context: __dirname, 
    devtool: debug ? "inline-sourcemap" : null, 
    entry: { 
     app: "./wwwroot/js/app.js", 
     lib: "./wwwroot/lib/jPlayer/dist/jplayer/jquery.jplayer.js" 
    }, 
    module: { 
     loaders: [ 
      { 
       test: /\.jsx?$/, 
       exclude: /(node_modules|bower_components)/, 
       loader: "babel-loader", 
       query: { 
        presets: ["react", "es2015", "stage-0"], 
        plugins: ["react-html-attrs", "transform-class-properties", "transform-decorators-legacy"], 
       } 
      } 
     ] 
    }, 
    output: { 
     path: "./wwwroot/build/", 
     filename: "[name].js" 
    }, 
    plugins: debug ? [] : [ 
     new webpack.optimize.DedupePlugin(), 
     new webpack.optimize.OccurenceOrderPlugin(), 
     new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }) 
    ] 
}; 

답변

1

이 코드는 번들로 제공되는 jQuery를 제외 :

externals: { 
    "jquery": "jQuery" 
}, 
0

당신은 웹팩에서 플러그인을 제공 사용할 수

new webpack.ProvidePlugin({ 
    $: "jquery", 
    jQuery: "jquery" 
}) 
관련 문제