webpack.base.conf.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 vuxLoader = require('vux-loader')
  7. function resolve(dir) {
  8. return path.join(__dirname, '..', dir)
  9. }
  10. const webpackConfig = module.exports = {
  11. entry: {
  12. app: './src/main.js'
  13. },
  14. output: {
  15. path: config.build.assetsRoot,
  16. filename: '[name].js',
  17. publicPath: process.env.NODE_ENV === 'production' ?
  18. config.build.assetsPublicPath : config.dev.assetsPublicPath
  19. },
  20. resolve: {
  21. extensions: ['.js', '.vue', '.json'],
  22. alias: {
  23. 'vue$': 'vue/dist/vue.esm.js',
  24. '@': resolve('src'),
  25. }
  26. },
  27. module: {
  28. rules: [{
  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. }
  65. module.exports = vuxLoader.merge(webpackConfig, {
  66. plugins: ['vux-ui', 'progress-bar', 'duplicate-style',
  67. {
  68. name: 'less-theme',
  69. path: 'src/theme.less'
  70. }
  71. ]
  72. })