webpack.base.conf.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. var path = require('path')
  2. var utils = require('./utils')
  3. var config = require('../config')
  4. var vueLoaderConfig = require('./vue-loader.conf')
  5. function resolve (dir) {
  6. return path.join(__dirname, '..', dir)
  7. }
  8. module.exports = {
  9. entry: {
  10. app: './src/main.js'
  11. },
  12. output: {
  13. path: config.build.assetsRoot,
  14. filename: '[name].js',
  15. publicPath: process.env.NODE_ENV === 'production'
  16. ? config.build.assetsPublicPath
  17. : config.dev.assetsPublicPath
  18. },
  19. resolve: {
  20. extensions: ['.js', '.vue', '.json'],
  21. alias: {
  22. 'vue$': 'vue/dist/vue.esm.js',
  23. '@': resolve('src')
  24. }
  25. },
  26. module: {
  27. rules: [
  28. {
  29. test: /\.(js|vue)$/,
  30. loader: 'eslint-loader',
  31. enforce: 'pre',
  32. include: [resolve('src'), resolve('test')],
  33. options: {
  34. formatter: require('eslint-friendly-formatter')
  35. }
  36. },
  37. {
  38. test: /\.vue$/,
  39. loader: 'vue-loader',
  40. options: vueLoaderConfig
  41. },
  42. {
  43. test: /\.js$/,
  44. loader: 'babel-loader',
  45. include: [resolve('src'), resolve('test')]
  46. },
  47. {
  48. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  49. loader: 'url-loader',
  50. options: {
  51. limit: 10000,
  52. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  53. }
  54. },
  55. {
  56. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  57. loader: 'url-loader',
  58. options: {
  59. limit: 10000,
  60. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  61. }
  62. },
  63. {
  64. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  65. loader: 'url-loader',
  66. options: {
  67. limit: 10000,
  68. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  69. }
  70. }
  71. ]
  72. }
  73. }