You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

webpack.chart.conf.js 1.3KB

4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * @Author: Caven
  3. * @Date: 2021-03-14 00:41:29
  4. */
  5. 'use strict'
  6. const path = require('path')
  7. const webpack = require('webpack')
  8. const JavaScriptObfuscator = require('webpack-obfuscator')
  9. const common = require('./common')
  10. module.exports = env => {
  11. const IS_PROD = (env && env.production) || false
  12. const publicPath = IS_PROD ? '/' : '/'
  13. let plugins = [...common.plugins]
  14. if (IS_PROD) {
  15. plugins.push(new webpack.NoEmitOnErrorsPlugin())
  16. plugins.push(
  17. new JavaScriptObfuscator(
  18. {
  19. rotateStringArray: true
  20. },
  21. []
  22. )
  23. )
  24. }
  25. return {
  26. entry: {
  27. 'dc.chart': ['entry']
  28. },
  29. devtool: IS_PROD ? false : 'cheap-module-eval-source-map',
  30. output: {
  31. filename: IS_PROD ? '[name].min.js' : '[name].js',
  32. path: path.resolve(__dirname, '..', 'packages/chart/dist'),
  33. publicPath: publicPath,
  34. library: 'DcChart',
  35. libraryExport: 'default',
  36. libraryTarget: 'umd',
  37. umdNamedDefine: true
  38. },
  39. module: {
  40. unknownContextCritical: false,
  41. rules: common.rules
  42. },
  43. resolve: {
  44. extensions: ['.js', '.json', '.css'],
  45. alias: {
  46. '@dc-modules': path.resolve(__dirname, '..', 'modules'),
  47. entry: path.resolve(__dirname, '..', 'packages/chart/index.js')
  48. }
  49. },
  50. plugins
  51. }
  52. }