webpack.base.conf.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. const manifest = require('../vendor-manifest.json')
  7. function resolve(dir) {
  8. return path.join(__dirname, '..', dir)
  9. }
  10. module.exports = {
  11. entry: {
  12. // app: './src/main.js',
  13. app: ['babel-polyfill', './src/main.js']
  14. },
  15. output: {
  16. path:process.env.NODE_ENV === 'production'? config.build.assetsRoot:config.test.assetsRoot,
  17. filename: '[name].js',
  18. publicPath: process.env.NODE_ENV === 'production'
  19. ? config.build.assetsPublicPath
  20. :process.env.NODE_ENV === 'test'
  21. ?config.test.assetsPublicPath
  22. :config.dev.assetsPublicPath
  23. },
  24. resolve: {
  25. extensions: ['.js', '.vue', '.json'],
  26. alias: {
  27. 'vue$': 'vue/dist/vue.esm.js',
  28. '@': resolve('src'),
  29. 'scss_vars': '@/styles/vars.scss',
  30. 'index_scss': '@/styles/index.scss',
  31. 'api': '@/api',
  32. 'utils': '@/utils',
  33. 'components': '@/components',
  34. 'common': '@/common'
  35. }
  36. },
  37. externals:{
  38. "vue":"Vue",
  39. "echarts": 'echarts'
  40. },
  41. plugins: [
  42. new webpack.DllReferencePlugin({
  43. manifest
  44. })
  45. ],
  46. module: {
  47. rules: [
  48. {
  49. test: /\.vue$/,
  50. loader: 'vue-loader',
  51. options: vueLoaderConfig
  52. },
  53. {
  54. test: /\.js$/,
  55. loader: 'babel-loader',
  56. include: [
  57. resolve('src'),
  58. resolve('static'),
  59. resolve('/node_modules/element-ui'),
  60. ]
  61. },
  62. {
  63. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  64. loader: 'url-loader',
  65. options: {
  66. limit: 10000,
  67. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  68. }
  69. },
  70. {
  71. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  72. loader: 'url-loader',
  73. options: {
  74. limit: 10000,
  75. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  76. }
  77. }
  78. ]
  79. }
  80. }