webpack.base.conf.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. 'use strict'
  2. const path = require('path')
  3. const utils = require('./utils')
  4. const config = require('../config')
  5. const vueLoaderConfig = require('./vue-loader.conf')
  6. const cesiumSource = '../node_modules/cesium/Source';
  7. function resolve(dir) {
  8. return path.join(__dirname, '..', dir)
  9. }
  10. module.exports = {
  11. context: path.resolve(__dirname, '../'),
  12. entry: {
  13. app: './src/main.js'
  14. // app: ["classlist-polyfill","babel-polyfill", "./src/main.js"]
  15. },
  16. output: {
  17. path: config.build.assetsRoot,
  18. filename: '[name].js',
  19. publicPath: process.env.NODE_ENV === 'production'
  20. ? config.build.assetsPublicPath
  21. : config.dev.assetsPublicPath,
  22. sourcePrefix: ''
  23. },
  24. amd: {
  25. toUrlUndefined: true,
  26. },
  27. resolve: {
  28. extensions: ['.js', '.vue', '.json'],
  29. alias: {
  30. 'vue$': 'vue/dist/vue.esm.js',
  31. '@': resolve('src'),
  32. // '@cesium': path.resolve(__dirname, cesiumSource),
  33. 'static': path.resolve(__dirname, '../static'),
  34. }
  35. },
  36. module: {
  37. unknownContextCritical: false,
  38. rules: [
  39. {
  40. test: /\.vue$/,
  41. loader: 'vue-loader',
  42. options: vueLoaderConfig
  43. },
  44. {
  45. test: /\.js$/,
  46. loader: 'babel-loader',
  47. include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client'),resolve('node_modules/cesium')],
  48. },
  49. {
  50. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  51. loader: 'url-loader',
  52. options: {
  53. limit: 10000,
  54. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  55. }
  56. },
  57. {
  58. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  59. loader: 'url-loader',
  60. options: {
  61. limit: 10000,
  62. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  63. }
  64. },
  65. {
  66. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  67. loader: 'url-loader',
  68. options: {
  69. limit: 10000,
  70. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  71. }
  72. },
  73. {
  74. test: /view-design.src.*?js$/,
  75. loader: 'babel-loader'
  76. }
  77. ]
  78. },
  79. node: {
  80. // prevent webpack from injecting useless setImmediate polyfill because Vue
  81. // source contains it (although only uses it if it's native).
  82. setImmediate: false,
  83. // prevent webpack from injecting mocks to Node native modules
  84. // that does not make sense for the client
  85. dgram: 'empty',
  86. fs: 'empty',
  87. net: 'empty',
  88. tls: 'empty',
  89. child_process: 'empty'
  90. }
  91. }