webpack.config.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. const path = require('path');
  2. const VueLoaderPlugin = require('vue-loader/lib/plugin')
  3. const pathUrl = "dist"
  4. module.exports = {
  5. entry: {
  6. singleSpaEntry:['src/singleSpaEntry.js']
  7. },
  8. output: {
  9. filename: '[name].js',
  10. path: path.resolve(__dirname, 'dist'),
  11. libraryTarget: 'umd',
  12. library: pathUrl,
  13. },
  14. module: {
  15. rules: [
  16. {
  17. test: /\.vue$/,
  18. loader: 'vue-loader',
  19. options: {
  20. loaders: {
  21. js: 'babel-loader'
  22. },
  23. },
  24. },
  25. {
  26. test: /\.js$/,
  27. loader: 'babel-loader',
  28. exclude: /node_modules/,
  29. include: path.join(__dirname, './src'),
  30. },
  31. {
  32. test: /\.(png|jpg|gif|svg)$/,
  33. loader: 'file-loader',
  34. options: {
  35. limit: 100000,
  36. name: '[name].[ext]?[hash]',
  37. publicPath: `./${pathUrl}/`,
  38. }
  39. },
  40. {
  41. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  42. loader: 'url-loader',
  43. options: {
  44. limit: 100000,
  45. name: 'fonts/[name].[hash:7].[ext]',
  46. publicPath: `./${pathUrl}/`,
  47. }
  48. },
  49. {
  50. test: /\.css$/,
  51. use: [
  52. 'vue-style-loader',
  53. 'css-loader'
  54. ]
  55. },
  56. {
  57. test: /\.scss$/,
  58. loaders: ["vue-style-loader", "css-loader", "sass-loader"]
  59. }
  60. ]
  61. },
  62. resolve: {
  63. alias: {
  64. 'vue$': 'vue/dist/vue.esm.js',
  65. '@': path.join(__dirname, './src'),
  66. },
  67. extensions: [
  68. ".js", ".vue"
  69. ],
  70. modules: [
  71. __dirname,
  72. 'node_modules',
  73. ],
  74. },
  75. mode: 'development',
  76. devtool: 'none',
  77. externals: [],
  78. plugins: [
  79. new VueLoaderPlugin()
  80. ],
  81. devServer: {
  82. // host:'192.168.40.203',
  83. contentBase: './release',
  84. historyApiFallback: true,
  85. watchOptions: { aggregateTimeout: 300, poll: 1000 },
  86. headers: {
  87. "Access-Control-Allow-Origin": "*",
  88. "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
  89. "Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
  90. },
  91. // Proxy config for development purposes. In production, you would configure you webserver to do something similar.
  92. proxy: {
  93. // "/grainReserves": {
  94. // target: "http://localhost:9004",
  95. // pathRewrite: { "^/grainReserves": "" },
  96. // },
  97. // "/myuser": {
  98. // target: "http://218.241.206.66:8097/myuser",
  99. // pathRewrite: {"^/myuser" : ""},
  100. // },
  101. // "/myuser": {
  102. // target: "http://192.168.80.230:8097/myuser",
  103. // pathRewrite: { "^/myuser": "" },
  104. // },
  105. '/api': {
  106. target: 'http://lswz:9090/api', //
  107. secure: false, // 如果是https接口,需要配置这个参数
  108. changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
  109. pathRewrite: {
  110. '^/api': ''
  111. }
  112. },
  113. },
  114. }
  115. };