webpack.base.conf.js 2.0 KB

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