2017-07-13 9 views
1

webpackバージョン3.2.0を使用しています。
webpackコマンドはうまく機能していますが、webpack -pはエラースタックを下回ります。webpack -pエラー:UglifyJsのbundle.jsのエラー

ERROR in bundle.js from UglifyJs 
Unexpected character '`' [bundle.js:1168,19] 

マイファイルのJavaScriptファイルにバッククォートが含まれています。

`<div style="display: table; width: 100%; height: 100%;"> 
    <div style="display: table-cell; vertical-align: middle;text-align: center;width: 100%;"> 
     <button class="w2ui-btn" id="alloc_fund_save_btn">Save</button> 
    </div> 
    </div>` 

は、ここに私のwebpack.config.js

const path = require('path'); 
var webpack = require('/usr/local/lib/node_modules/webpack'); 

config = { 
    // define entry point 
    entry: "./src/index.js", 

    // define output point 
    output: { 
     path: path.resolve(__dirname, ''), // no need to create folder 
     filename: 'bundle.js' 
    }, 
    module: { 
     rules: [{ 
       test: require.resolve('./jquery.min.js'), 
       use: [{ 
        loader: 'expose-loader', 
        options: 'jQuery' 
       },{ 
        loader: 'expose-loader', 
        options: '$' 
       }] 
      }] 
    } 
}; 

module.exports = config; 

私は私の設定と統合するために不足しています任意のプラグインがあります。

ご協力いただければ幸いです。

答えて

0

UglifyjsWebpackPluginは、ES6コードの縮小をサポートしていません。

バベルローダーを追加するか、手動でuglify-js依存関係を変更する必要があります。私はバベルローダーを使用することをお勧めします。

From UglifyjsWebpackPlugin docs

Important! The plugin has a peer dependency to uglify-js, so in order to use the plugin, also uglify-js has to be installed. The currently (2017/1/25) available uglify-js npm packages; however, do not support minification of ES6 code. In order to support ES6, an ES6-capable, a.k.a. harmony, version of UglifyJS has to be provided. If your minification target is ES6: yarn add git://github.com/mishoo/UglifyJS2#harmony-v2.8.22 --dev

関連する問題