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.base.conf.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @Author: Caven
  3. * @Date: 2021-03-13 16:52:10
  4. */
  5. 'use strict'
  6. const path = require('path')
  7. const webpack = require('webpack')
  8. const CopyWebpackPlugin = require('copy-webpack-plugin')
  9. const common = require('./common')
  10. let cesiumCopyPlugin = [
  11. new CopyWebpackPlugin([
  12. {
  13. from: path.resolve(
  14. __dirname,
  15. '../node_modules/@cesium/engine/Source',
  16. 'Assets'
  17. ),
  18. to: 'resources/Assets'
  19. },
  20. {
  21. from: path.resolve(
  22. __dirname,
  23. '../node_modules/@cesium/engine/Build',
  24. 'Workers'
  25. ),
  26. to: 'resources/Workers'
  27. },
  28. {
  29. from: path.resolve(
  30. __dirname,
  31. '../node_modules/@cesium/engine/Source',
  32. 'ThirdParty'
  33. ),
  34. to: 'resources/ThirdParty'
  35. }
  36. ])
  37. ]
  38. module.exports = env => {
  39. const IS_PROD = (env && env.production) || false
  40. const publicPath = IS_PROD ? '/' : '/'
  41. let plugins = [...cesiumCopyPlugin, ...common.plugins]
  42. if (IS_PROD) {
  43. plugins.push(new webpack.NoEmitOnErrorsPlugin())
  44. }
  45. return {
  46. entry: {
  47. 'dc.base': path.resolve(__dirname, '..', 'packages/base/index.js')
  48. },
  49. devtool: IS_PROD ? false : 'cheap-module-eval-source-map',
  50. output: {
  51. filename: IS_PROD ? '[name].min.js' : '[name].js',
  52. path: path.resolve(__dirname, '..', 'packages/base/dist'),
  53. publicPath: publicPath,
  54. library: 'DC',
  55. libraryExport: 'default',
  56. libraryTarget: `umd`,
  57. umdNamedDefine: true
  58. },
  59. module: {
  60. unknownContextCritical: false,
  61. rules: common.rules
  62. },
  63. resolve: {
  64. extensions: ['.js', '.json', '.css'],
  65. alias: {
  66. '@dc-modules': path.resolve(__dirname, '..', 'modules')
  67. }
  68. },
  69. performance: common.performance,
  70. plugins
  71. }
  72. }