webpack.base.conf.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. },
  19. output: {
  20. path: config.build.assetsRoot,
  21. filename: '[name].js',
  22. publicPath: process.env.NODE_ENV === 'production'
  23. ? config.build.assetsPublicPath
  24. : config.dev.assetsPublicPath
  25. },
  26. resolve: {
  27. extensions: ['.js', '.vue', '.json'],
  28. alias: {
  29. 'vue$': 'vue/dist/vue.esm.js',
  30. '@': resolve('src'),
  31. 'scss_vars': '@/styles/vars.scss'
  32. }
  33. },
  34. plugins: [
  35. new webpack.ProvidePlugin({
  36. jQuery: 'jquery',
  37. $: 'jquery'
  38. })
  39. ],
  40. module: {
  41. rules: [
  42. {
  43. test: /\.vue$/,
  44. loader: 'vue-loader',
  45. options: vueLoaderConfig
  46. },
  47. {
  48. test: /\.js$/,
  49. loader: 'babel-loader',
  50. include: [resolve('src'), resolve('test')]
  51. },
  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. {
  61. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  62. loader: 'url-loader',
  63. options: {
  64. limit: 10000,
  65. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  66. }
  67. }
  68. ]
  69. }
  70. }