webpack.base.conf.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. var path = require('path')
  2. var utils = require('./utils')
  3. var config = require('../config')
  4. var vueLoaderConfig = require('./vue-loader.conf')
  5. const webpack = require('webpack')
  6. function resolve(dir) {
  7. return path.join(__dirname, '..', dir)
  8. }
  9. const src = path.resolve(__dirname, '../src')
  10. module.exports = {
  11. entry: {
  12. app: './src/main.js'
  13. },
  14. output: {
  15. path: config.build.assetsRoot,
  16. filename: '[name].js',
  17. publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath
  18. },
  19. resolve: {
  20. extensions: ['.js', '.vue', '.json'],
  21. alias: {
  22. 'vue$': 'vue/dist/vue.esm.js',
  23. '@': resolve('src'),
  24. 'src': path.resolve(__dirname, '../src'),
  25. 'assets': path.resolve(__dirname, '../src/assets'),
  26. 'components': path.resolve(__dirname, '../src/components'),
  27. 'views': path.resolve(__dirname, '../src/views'),
  28. 'styles': path.resolve(__dirname, '../src/styles'),
  29. 'api': path.resolve(__dirname, '../src/api'),
  30. 'utils': path.resolve(__dirname, '../src/utils'),
  31. 'store': path.resolve(__dirname, '../src/store'),
  32. 'router': path.resolve(__dirname, '../src/router'),
  33. // 'static': path.resolve(__dirname, '../static')
  34. 'jquery': 'jquery'
  35. }
  36. },
  37. plugins: [
  38. new webpack.ProvidePlugin({
  39. $: 'jquery',
  40. jQuery: 'jquery'
  41. })
  42. ],
  43. module: {
  44. rules: [{
  45. test: /\.vue$/,
  46. loader: 'vue-loader',
  47. options: vueLoaderConfig
  48. }, {
  49. test: /\.js$/,
  50. loader: 'babel-loader',
  51. include: [resolve('src'), resolve('test')]
  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. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  61. loader: 'url-loader',
  62. options: {
  63. limit: 10000,
  64. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  65. }
  66. }]
  67. }
  68. }