webpack.base.conf.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. var path = require('path')
  2. var utils = require('./utils')
  3. var config = require('../config')
  4. var vueLoaderConfig = require('./vue-loader.conf')
  5. function resolve (dir) {
  6. return path.join(__dirname, '..', dir)
  7. }
  8. module.exports = {
  9. entry: {
  10. app: './src/main.js'
  11. },
  12. output: {
  13. path: config.build.assetsRoot,
  14. filename: '[name].js',
  15. publicPath: process.env.NODE_ENV === 'production'
  16. ? config.build.assetsPublicPath
  17. : config.dev.assetsPublicPath
  18. },
  19. resolve: {
  20. extensions: ['.js', '.vue', '.json'],
  21. alias: {
  22. 'vue$': 'vue/dist/vue.esm.js',
  23. '@': resolve('src'),
  24. }
  25. },
  26. module: {
  27. rules: [
  28. {
  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. query: {
  42. limit: 10000,
  43. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  44. }
  45. },
  46. {
  47. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  48. loader: 'url-loader',
  49. query: {
  50. limit: 10000,
  51. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  52. }
  53. }
  54. ]
  55. }
  56. }