webpack.base.conf.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. var path = require('path')
  2. var utils = require('./utils')
  3. var config = require('../config')
  4. var vueLoaderConfig = require('./vue-loader.conf')
  5. const vuxLoader = require('vux-loader')
  6. //引入多页面支持
  7. var multipageHelper = require('./multipage-helper')
  8. function resolve(dir) {
  9. return path.join(__dirname, '..', dir)
  10. }
  11. const webpackConfig={
  12. entry: multipageHelper.getEntries(), //设置入口集合
  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. }
  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: /\.less$/,
  40. loader: 'style-loader!css-loader!less-loader'
  41. },
  42. {
  43. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  44. loader: 'url-loader',
  45. options: {
  46. limit: 10000,
  47. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  48. }
  49. },
  50. {
  51. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  52. loader: 'url-loader',
  53. options: {
  54. limit: 10000,
  55. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  56. }
  57. }
  58. ]
  59. }
  60. }
  61. module.exports = vuxLoader.merge(webpackConfig, {
  62. plugins: ['vux-ui']
  63. })