webpack.base.conf.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. var path = require('path')
  2. var utils = require('./utils')
  3. var config = require('../config')
  4. var vueLoaderConfig = require('./vue-loader.conf')
  5. var webpack = require('webpack')
  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. '@': 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:/\.css$/,
  40. // loader:"postcss-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: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  52. loader: 'url-loader',
  53. options: {
  54. limit: 10000,
  55. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  56. }
  57. },
  58. {
  59. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  60. loader: 'url-loader',
  61. options: {
  62. limit: 10000,
  63. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  64. }
  65. },
  66. {
  67. test: /\.js$/,
  68. loader: 'babel-loader',
  69. options:{
  70. presets:["es2015"]
  71. },
  72. exclude:[/node_modules/]
  73. },
  74. ]
  75. },
  76. // plugins:[
  77. // new webpack.LoaderOptionsPlugin({
  78. // postcss:postcssConfig,
  79. // })
  80. // ]
  81. }