webpack.dll.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * @author oldj
  3. * @blog https://oldj.net
  4. */
  5. 'use strict'
  6. const path = require('path')
  7. const webpack = require('webpack')
  8. const moment = require('moment')
  9. const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
  10. const basedir = path.dirname(__dirname)
  11. const vendors = [
  12. 'react', 'react-dom', 'antd', 'lodash',
  13. 'moment', 'classnames', 'codemirror'
  14. ]
  15. module.exports = {
  16. mode: 'production',
  17. entry: {
  18. 'common': vendors
  19. },
  20. output: {
  21. path: path.join(basedir, 'app', 'ui'),
  22. filename: '[name].js',
  23. library: '[name]'
  24. },
  25. optimization: {
  26. minimizer: [
  27. new UglifyJsPlugin({
  28. cache: true,
  29. parallel: true,
  30. uglifyOptions: {
  31. compress: true,
  32. ecma: 6,
  33. mangle: true,
  34. output: {
  35. ascii_only: true
  36. }
  37. },
  38. sourceMap: true
  39. })
  40. ]
  41. },
  42. plugins: [
  43. new webpack.DllPlugin({
  44. path: path.join(basedir, 'tmp', 'manifest.json'),
  45. name: '[name]',
  46. context: basedir
  47. }),
  48. new webpack.BannerPlugin(`SwitchHosts! common.js, ${moment().format('YYYY-MM-DD HH:mm:ss')}`)
  49. ]
  50. }