Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

webpack.core.conf.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-01-18 19:22:23
  4. */
  5. const path = require('path')
  6. const webpack = require('webpack')
  7. const MiniCssExtractPlugin = require('mini-css-extract-plugin')
  8. const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
  9. const JavaScriptObfuscator = require('webpack-obfuscator')
  10. const cesiumBuild = '../node_modules/cesium/Build/Cesium'
  11. const common = require('./common')
  12. module.exports = env => {
  13. const IS_PROD = (env && env.production) || false
  14. const publicPath = IS_PROD ? '/' : '/'
  15. let plugins = [
  16. new MiniCssExtractPlugin({
  17. filename: IS_PROD ? '[name].min.css' : '[name].css',
  18. allChunks: true
  19. }),
  20. ...common.plugins
  21. ]
  22. if (IS_PROD) {
  23. plugins.push(new OptimizeCssAssetsPlugin())
  24. plugins.push(new webpack.NoEmitOnErrorsPlugin())
  25. plugins.push(
  26. new JavaScriptObfuscator(
  27. {
  28. rotateStringArray: true
  29. },
  30. []
  31. )
  32. )
  33. }
  34. return {
  35. entry: {
  36. 'dc.core': ['theme', 'entry']
  37. },
  38. devtool: IS_PROD ? false : 'cheap-module-eval-source-map',
  39. output: {
  40. filename: IS_PROD ? '[name].min.js' : '[name].js',
  41. path: path.resolve(
  42. __dirname,
  43. path.resolve(__dirname, '..', 'packages/core/dist')
  44. ),
  45. publicPath: publicPath,
  46. library: 'DcCore',
  47. libraryExport: 'default',
  48. libraryTarget: 'umd',
  49. umdNamedDefine: true
  50. },
  51. module: {
  52. unknownContextCritical: false,
  53. rules: common.rules
  54. },
  55. resolve: {
  56. extensions: ['.js', '.json', '.css'],
  57. alias: {
  58. '@dc-modules': path.resolve(__dirname, '..', 'modules'),
  59. entry: path.resolve(__dirname, '..', 'packages/core/index.js'),
  60. theme: path.resolve(__dirname, '..', 'modules/themes/index.js'),
  61. cesium: path.resolve(__dirname, cesiumBuild)
  62. }
  63. },
  64. performance: common.performance,
  65. plugins
  66. }
  67. }