mirror of
https://github.com/infeng/react-viewer.git
synced 2025-12-08 17:36:40 +00:00
40 lines
820 B
JavaScript
40 lines
820 B
JavaScript
const config = require('./webpack.config.common');
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
const fs = require('fs-extra');
|
|
const path = require('path');
|
|
|
|
const distPath = path.join(__dirname, 'dist');
|
|
if (fs.existsSync(distPath)) {
|
|
fs.removeSync(distPath);
|
|
}
|
|
|
|
config.output.merge({
|
|
library: 'react-viewer',
|
|
libraryTarget: 'umd',
|
|
globalObject: 'this'
|
|
});
|
|
|
|
config.mode('production');
|
|
|
|
config.externals({
|
|
react: {
|
|
root: 'React',
|
|
commonjs2: 'react',
|
|
commonjs: 'react',
|
|
amd: 'react',
|
|
},
|
|
'react-dom': {
|
|
root: 'ReactDOM',
|
|
commonjs2: 'react-dom',
|
|
commonjs: 'react-dom',
|
|
amd: 'react-dom',
|
|
},
|
|
});
|
|
|
|
if (process.env.ANALYZE) {
|
|
config.plugin('BundleAnalyzerPlugin')
|
|
.use(BundleAnalyzerPlugin);
|
|
}
|
|
|
|
module.exports = config.toConfig();
|