webpack.package.config.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. const paths = require('./paths');
  2. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  3. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  4. module.exports = {
  5. entry: paths.appPackageJs,
  6. mode: "production",
  7. output: {
  8. publicPath: "/dist/",
  9. libraryTarget: "umd",
  10. library: ['schema'],
  11. filename: '[name].js'
  12. },
  13. module: {
  14. rules: [
  15. {
  16. test: /\.js$/,
  17. exclude: /node_modules/,
  18. use: {
  19. loader: "babel-loader"
  20. }
  21. },
  22. {
  23. test: /\.css$/,
  24. use: [MiniCssExtractPlugin.loader, 'css-loader'],
  25. },
  26. {
  27. test: /\.less$/,
  28. use: ["style-loader", "css-loader", {
  29. loader: 'less-loader',
  30. options: {
  31. javascriptEnabled: true,
  32. },
  33. }]
  34. }
  35. ]
  36. },
  37. plugins: [
  38. new MiniCssExtractPlugin(),
  39. new BundleAnalyzerPlugin(
  40. {
  41. analyzerMode: 'server',
  42. analyzerHost: '127.0.0.1',
  43. analyzerPort: 8889,
  44. reportFilename: 'report.html',
  45. defaultSizes: 'parsed',
  46. openAnalyzer: true,
  47. generateStatsFile: false,
  48. statsFilename: 'stats.json',
  49. statsOptions: null,
  50. logLevel: 'info'
  51. }
  52. ),
  53. ],
  54. externals: [
  55. { react: { commonjs: "react", commonjs2: "react", amd: 'react', root: ['React'] } },
  56. { "react-redux": { commonjs: "react-redux", commonjs2: "react-redux", amd: "react-redux" } },
  57. { lodash: { commonjs: "lodash", commonjs2: "lodash", amd: 'lodash', root: ['_'] } },
  58. { brace: { commonjs: "brace", commonjs2: "brace", amd: 'brace', root: ['ace'] } },
  59. { "brace/mode/json": { commonjs: "brace/mode/json", commonjs2: "brace/mode/json", amd: 'brace/mode/json', root: ['brace/mode/json'] } },
  60. { moox: { commonjs: "moox", commonjs2: "moox", amd: 'moox' } },
  61. { "react-dom": { commonjs: "react-dom", commonjs2: "react-dom", amd: 'react-dom', root: ['ReactDom'] } },
  62. { redux: { commonjs: "redux", commonjs2: "redux", amd: 'redux' } },
  63. { "prop-types": { commonjs: "prop-types", commonjs2: "prop-types", amd: 'prop-types' } },
  64. { "moment": { commonjs: "moment", commonjs2: "moment", amd: 'moment' } },
  65. { antd: { commonjs: "antd", commonjs2: "antd", amd: 'antd' } },
  66. { "form-render": { commonjs: "form-render", commonjs2: "form-render", amd: 'form-render', root: ['FormRender'] } },
  67. // 匹配以 "library/" 开始的所有依赖
  68. /^antd\/.+$/,
  69. /^form-render\/.+$/,
  70. /^@ant-design\/.+$/
  71. ]
  72. };