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.

85 line
2.1KB

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