webpack.base.conf.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. 'use strict'
  2. const path = require('path')
  3. const utils = require('./utils')
  4. const config = require('../config')
  5. const vueLoaderConfig = require('./vue-loader.conf')
  6. const webpack = require('webpack')
  7. function resolve (dir) {
  8. return path.join(__dirname, '..', dir)
  9. }
  10. const createLintingRule = () => ({
  11. test: /\.(js|vue)$/,
  12. loader: 'eslint-loader',
  13. enforce: 'pre',
  14. include: [resolve('src'), resolve('test')],
  15. options: {
  16. formatter: require('eslint-friendly-formatter'),
  17. emitWarning: !config.dev.showEslintErrorsInOverlay
  18. }
  19. })
  20. module.exports = {
  21. context: path.resolve(__dirname, '../'),
  22. entry: {
  23. app:['babel-polyfill','./src/main.js']
  24. },
  25. externals: {
  26. vue: 'Vue',
  27. axios: 'axios',
  28. 'vue-router': 'VueRouter',
  29. 'element-ui': 'ELEMENT',
  30. // "QPlayer": "QPlayer"
  31. },
  32. output: {
  33. path: config.build.assetsRoot,
  34. filename: '[name].js',
  35. publicPath: process.env.NODE_ENV === 'production'
  36. ? config.build.assetsPublicPath
  37. : config.dev.assetsPublicPath
  38. },
  39. resolve: {
  40. extensions: ['.js', '.vue', '.json'],
  41. alias: {
  42. 'vue$': 'vue/dist/vue.esm.js',
  43. '@': resolve('src'),
  44. }
  45. },
  46. plugins: [
  47. new webpack.ProvidePlugin({
  48. $: "jquery",
  49. jQuery: "jquery"
  50. })
  51. ],
  52. module: {
  53. rules: [
  54. ...(config.dev.useEslint ? [createLintingRule()] : []),
  55. {
  56. test: /\.vue$/,
  57. loader: 'vue-loader',
  58. options: vueLoaderConfig
  59. },
  60. {
  61. test: /\.js$/,
  62. loader: 'babel-loader',
  63. include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
  64. },
  65. {
  66. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  67. loader: 'url-loader',
  68. options: {
  69. limit: 10000,
  70. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  71. }
  72. },
  73. {
  74. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  75. loader: 'url-loader',
  76. options: {
  77. limit: 10000,
  78. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  79. }
  80. },
  81. {
  82. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  83. loader: 'url-loader',
  84. options: {
  85. limit: 10000,
  86. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  87. }
  88. }
  89. ]
  90. },
  91. node: {
  92. // prevent webpack from injecting useless setImmediate polyfill because Vue
  93. // source contains it (although only uses it if it's native).
  94. setImmediate: false,
  95. // prevent webpack from injecting mocks to Node native modules
  96. // that does not make sense for the client
  97. dgram: 'empty',
  98. fs: 'empty',
  99. net: 'empty',
  100. tls: 'empty',
  101. child_process: 'empty'
  102. }
  103. }