Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

webpack.core.conf.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. 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. entry: path.resolve(__dirname, '..', 'packages/core/index.js'),
  59. theme: path.resolve(__dirname, '..', 'modules/themes/index.js'),
  60. cesium: path.resolve(__dirname, cesiumBuild)
  61. }
  62. },
  63. plugins
  64. }
  65. }