webpack.base.conf.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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$/,
  41. loader: 'vue-loader',
  42. options: vueLoaderConfig
  43. },
  44. {
  45. test: /\.js$/,
  46. loader: 'babel-loader',
  47. include: [resolve('src'), resolve('test')]
  48. },
  49. {
  50. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  51. loader: 'url-loader',
  52. options: {
  53. limit: 10000,
  54. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  55. }
  56. },
  57. {
  58. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  59. loader: 'url-loader',
  60. options: {
  61. limit: 10000,
  62. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  63. }
  64. },
  65. {
  66. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  67. loader: 'url-loader',
  68. options: {
  69. limit: 10000,
  70. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  71. }
  72. }
  73. ]
  74. }
  75. }