webpack.base.conf.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. entry: {
  11. app: './src/main.js'
  12. },
  13. output: {
  14. path: config.build.assetsRoot,
  15. filename: '[name].js',
  16. publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath
  17. },
  18. resolve: {
  19. extensions: ['.js', '.vue', '.json'],
  20. alias: {
  21. vue$: 'vue/dist/vue.esm.js',
  22. '@': resolve('src'),
  23. jquery: path.resolve(__dirname, '../node_modules/jquery/src/jquery')
  24. }
  25. },
  26. module: {
  27. rules: [
  28. {
  29. test: /\.vue$/,
  30. loader: 'vue-loader',
  31. options: vueLoaderConfig
  32. },
  33. {
  34. test: /\.js$/,
  35. loader: 'babel-loader',
  36. include: [resolve('src'), resolve('test')]
  37. },
  38. {
  39. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  40. loader: 'url-loader',
  41. options: {
  42. limit: 10000,
  43. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  44. }
  45. },
  46. {
  47. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  48. loader: 'url-loader',
  49. options: {
  50. limit: 10000,
  51. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  52. }
  53. },
  54. {
  55. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  56. loader: 'url-loader',
  57. options: {
  58. limit: 10000,
  59. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  60. }
  61. }
  62. ]
  63. }
  64. }