webpack.dll.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 TerserPlugin = require('terser-webpack-plugin')
  10. const basedir = path.dirname(__dirname)
  11. const dependencies = Object.assign({}, require('../package.json').dependencies)
  12. module.exports = {
  13. mode: 'production',
  14. entry: {
  15. common: Object.keys(dependencies)
  16. },
  17. output: {
  18. path: path.join(basedir, 'app', 'ui'),
  19. filename: '[name].js',
  20. library: '[name]'
  21. },
  22. optimization: {
  23. minimizer: [
  24. new TerserPlugin({
  25. terserOptions: {
  26. output: {
  27. ecma: 5,
  28. comments: false,
  29. ascii_only: true
  30. }
  31. },
  32. parallel: true,
  33. cache: true,
  34. sourceMap: true
  35. })
  36. ]
  37. },
  38. plugins: [
  39. new webpack.DllPlugin({
  40. path: path.join(basedir, 'tmp', 'manifest.json'),
  41. name: '[name]',
  42. context: basedir
  43. }),
  44. new webpack.BannerPlugin(`SwitchHosts! common.js, ${moment().format('YYYY-MM-DD HH:mm:ss')}`)
  45. ]
  46. }