I am using webpack version 3.2.0.
webpack command is working fine but webpack -p
raises below error stack.
ERROR in bundle.js from UglifyJs
Unexpected character '`' [bundle.js:1168,19]
My file contains backtick in javascript file.
`<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>`
Here is my 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;
Is there any plugin that I am missing to integrate with my config.
Any help would be appreciated.
The problem is that
UglifyjsWebpackPlugin
doesn't support minification of ES6 code.You should add babel loader or change uglify-js dependency manually. I recommend you to use babel loader.
From UglifyjsWebpackPlugin docs: