webpack.base.conf.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. var path = require('path')
  2. var utils = require('./utils')
  3. var config = require('../config')
  4. var webpack = require('webpack')
  5. var vueLoaderConfig = require('./vue-loader.conf')
  6. function resolve(dir) {
  7. return path.join(__dirname, '..', dir)
  8. }
  9. module.exports = {
  10. entry: {
  11. app: './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.js',
  24. 'vue-router$': 'vue-router/dist/vue-router.common.js',
  25. '@': resolve('src'),
  26. 'api': '@/api',
  27. 'views': '@/views',
  28. 'utils': '@/utils'
  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: [resolve('src'), resolve('test')]
  42. },
  43. {
  44. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  45. loader: 'url-loader',
  46. query: {
  47. limit: 10000,
  48. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  49. }
  50. },
  51. {
  52. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  53. loader: 'url-loader',
  54. query: {
  55. limit: 10000,
  56. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  57. }
  58. }
  59. ]
  60. },
  61. plugins: [
  62. new webpack.ProvidePlugin({
  63. _: 'lodash',
  64. Vue: 'vue',
  65. moment: 'moment'
  66. })
  67. ]
  68. }