webpack.base.conf.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. var projectRoot = path.resolve(__dirname, '../')
  8. function resolve (dir) {
  9. return path.join(__dirname, '..', dir)
  10. }
  11. let webpackConfig = {
  12. context: path.resolve(__dirname, '../'),
  13. entry: {
  14. app: './src/main.js'
  15. },
  16. output: {
  17. path: config.build.assetsRoot,
  18. filename: '[name].js',
  19. publicPath: process.env.NODE_ENV === 'production'
  20. ? config.build.assetsPublicPath
  21. : config.dev.assetsPublicPath
  22. },
  23. resolve: {
  24. extensions: ['.js', '.vue', '.json'],
  25. alias: {
  26. 'vue$': 'vue/dist/vue.esm.js',
  27. '@': resolve('src'),
  28. 'sysStatic': resolve('src/assets'),
  29. }
  30. },
  31. module: {
  32. rules: [
  33. {
  34. test: /\.vue$/,
  35. loader: 'vue-loader',
  36. options: vueLoaderConfig
  37. },
  38. {
  39. test: /\.js$/,
  40. loader: 'babel-loader',
  41. include: [projectRoot],
  42. exclude: /node_modules/
  43. },
  44. // {
  45. // test: /vux.src.*?js$/,
  46. // loader: 'babel-loader',
  47. // options: {
  48. // presets: ['es2015']
  49. // },
  50. // include: [projectRoot],
  51. // },
  52. {
  53. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  54. loader: 'url-loader',
  55. options: {
  56. limit: 10000,
  57. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  58. }
  59. },
  60. {
  61. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  62. loader: 'url-loader',
  63. options: {
  64. limit: 10000,
  65. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  66. }
  67. },
  68. {
  69. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  70. loader: 'url-loader',
  71. options: {
  72. limit: 10000,
  73. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  74. }
  75. }
  76. ]
  77. }
  78. }
  79. module.exports = vuxLoader.merge(webpackConfig, {
  80. plugins: [
  81. 'vux-ui',
  82. 'progress-bar',
  83. {name: 'less-theme', path: 'src/assets/themes/vux/theme.less'},
  84. {
  85. name: 'duplicate-style',
  86. options: {
  87. cssProcessorOptions : {
  88. safe: true,
  89. zindex: false,
  90. autoprefixer: {
  91. add: true,
  92. browsers: [
  93. 'iOS >= 7',
  94. 'Android >= 4.1'
  95. ]
  96. }
  97. }
  98. }
  99. }
  100. ]
  101. })