webpack.base.conf.js 1.9 KB

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