No Description

webpack.base.conf.js 2.3KB

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