Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

webpack.core.conf.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * @Author: Caven
  3. * @Date: 2021-03-13 16:52:00
  4. */
  5. 'use strict'
  6. const path = require('path')
  7. const webpack = require('webpack')
  8. const MiniCssExtractPlugin = require('mini-css-extract-plugin')
  9. const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
  10. const JavaScriptObfuscator = require('webpack-obfuscator')
  11. const common = require('./common')
  12. const cesiumBuild = '../node_modules/cesium/Build/Cesium'
  13. module.exports = env => {
  14. const IS_PROD = (env && env.production) || false
  15. const publicPath = IS_PROD ? '/' : '/'
  16. let plugins = [
  17. new MiniCssExtractPlugin({
  18. filename: IS_PROD ? '[name].min.css' : '[name].css',
  19. allChunks: true
  20. })
  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': [
  37. path.resolve(__dirname, '..', 'packages/core/index.js'),
  38. path.resolve(__dirname, '..', 'modules/themes/index.js')
  39. ]
  40. },
  41. devtool: IS_PROD ? false : 'cheap-module-eval-source-map',
  42. output: {
  43. filename: IS_PROD ? '[name].min.js' : '[name].js',
  44. path: path.resolve(__dirname, '..', 'packages/core/dist'),
  45. publicPath: publicPath,
  46. library: 'DcCore',
  47. libraryTarget: 'umd',
  48. umdNamedDefine: true
  49. },
  50. module: {
  51. unknownContextCritical: false,
  52. rules: common.rules
  53. },
  54. resolve: {
  55. extensions: ['.js', '.json', '.css'],
  56. alias: {
  57. '@dc-modules': path.resolve(__dirname, '..', 'modules'),
  58. cesium: path.resolve(__dirname, cesiumBuild)
  59. }
  60. },
  61. plugins
  62. }
  63. }