webpack.base.conf.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. require( 'babel-polyfill')
  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: ["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. },
  23. resolve: {
  24. extensions: ['.js', '.vue', '.json'],
  25. alias: {
  26. 'vue$': 'vue/dist/vue.esm.js',
  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. options: {
  46. limit: 10000,
  47. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  48. }
  49. },
  50. {
  51. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  52. loader: 'url-loader',
  53. options: {
  54. limit: 10000,
  55. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  56. }
  57. },
  58. {
  59. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  60. loader: 'url-loader',
  61. options: {
  62. limit: 10000,
  63. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  64. }
  65. }
  66. ]
  67. },
  68. node: {
  69. // prevent webpack from injecting useless setImmediate polyfill because Vue
  70. // source contains it (although only uses it if it's native).
  71. setImmediate: false,
  72. // prevent webpack from injecting mocks to Node native modules
  73. // that does not make sense for the client
  74. dgram: 'empty',
  75. fs: 'empty',
  76. net: 'empty',
  77. tls: 'empty',
  78. child_process: 'empty'
  79. }
  80. }