webpack.base.conf.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. app: ["babel-polyfill", "./src/main.js"]
  13. },
  14. externals: {
  15. 'vue': 'Vue',
  16. 'vuex': 'Vuex',
  17. 'echarts': 'echarts',
  18. 'element-ui': 'ELEMENT'
  19. },
  20. output: {
  21. path: config.build.assetsRoot,
  22. filename: '[name].js',
  23. publicPath: process.env.NODE_ENV === 'production'
  24. ? config.build.assetsPublicPath
  25. : config.dev.assetsPublicPath
  26. },
  27. resolve: {
  28. extensions: ['.js', '.vue', '.json'],
  29. alias: {
  30. 'vue$': 'vue/dist/vue.esm.js',
  31. '@': resolve('src'),
  32. 'scss_vars': '@/styles/vars.scss'
  33. }
  34. },
  35. plugins: [
  36. new webpack.ProvidePlugin({
  37. jQuery: 'jquery',
  38. $: 'jquery'
  39. })
  40. ],
  41. module: {
  42. rules: [
  43. {
  44. test: /\.vue$/,
  45. loader: 'vue-loader',
  46. options: vueLoaderConfig
  47. },
  48. {
  49. test: /\.js$/,
  50. loader: 'babel-loader',
  51. include: [resolve('src'), resolve('test')]
  52. },
  53. {
  54. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  55. loader: 'url-loader',
  56. options: {
  57. limit: 10000,
  58. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  59. }
  60. },
  61. {
  62. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  63. loader: 'url-loader',
  64. options: {
  65. limit: 10000,
  66. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  67. }
  68. }
  69. ]
  70. }
  71. }