-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
When I set webpack config mode: 'production',it throw error:
ERROR in http.min.js from Terser
"Export" statement may only appear at the top level [http.min.js:1161,0]
But when I set mode: 'development',it works...I can't figure out why.
// http.js
const http = () => {}
http.version = '__version__';
export default http;// webpack.build-lib.js
const path = require('path');
const ReplacePlugin = require('../lib/webpack-plugin-replace');
const rootPath = path.resolve(__dirname, '..');
const pkg = require('../package.json');
const libName = 'http';
const entryFile = path.resolve(rootPath, `src/${libName}.js`);
module.exports = {
entry: entryFile,
mode: 'production',
output: {
path: path.resolve(rootPath, 'lib'),
filename: `${libName}.min.js`,
libraryTarget: 'umd2',
libraryExport: 'default',
},
plugins: [
new ReplacePlugin({
exclude: [
/node_modules/,
],
patterns: [{
regex: /__version__/g,
value: pkg.version,
}],
}),
],
};Metadata
Metadata
Assignees
Labels
No labels