No Description

webpack.config.umd.js 969B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const path = require('path');
  2. const prodConfig = require('./webpack.config.prod');
  3. const rootPath = process.cwd();
  4. const plugins = [...prodConfig.plugins];
  5. // 移除 CopyWebpackPlugin 与 HtmlWebpackPlugin
  6. plugins.pop();
  7. plugins.pop();
  8. const umdConfig = {
  9. ...prodConfig,
  10. devtool: 'source-map',
  11. output: {
  12. filename: '[name].js',
  13. path: path.resolve(rootPath, './dist'),
  14. // 默认不允许挂载在全局变量下
  15. // library: library,
  16. libraryTarget: 'umd'
  17. },
  18. externals: {
  19. // Don't bundle react or react-dom
  20. react: {
  21. commonjs: 'react',
  22. commonjs2: 'react',
  23. amd: 'React',
  24. root: 'React'
  25. },
  26. 'react-dom': {
  27. commonjs: 'react-dom',
  28. commonjs2: 'react-dom',
  29. amd: 'ReactDOM',
  30. root: 'ReactDOM'
  31. },
  32. 'styled-components': {
  33. commonjs: 'styled-components',
  34. commonjs2: 'styled-components'
  35. }
  36. },
  37. plugins
  38. };
  39. delete umdConfig.optimization;
  40. module.exports = umdConfig;