webpack.config - 副本.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. const path = require('path');
  2. const VueLoaderPlugin = require('vue-loader/lib/plugin')
  3. const CopyWebpackPlugin = require('copy-webpack-plugin')
  4. const projectName = "accountability"
  5. module.exports = {
  6. entry: {
  7. singleSpaEntry:['src/singleSpaEntry.js']
  8. },
  9. output: {
  10. filename: '[name].js',
  11. path: path.resolve(__dirname, 'accountability'),
  12. libraryTarget: 'umd',
  13. library: 'accountability',
  14. },
  15. module: {
  16. rules: [
  17. {
  18. test: /\.vue$/,
  19. loader: 'vue-loader',
  20. options: {
  21. loaders: {
  22. js: 'babel-loader'
  23. },
  24. },
  25. },
  26. {
  27. test: /\.js$/,
  28. loader: 'babel-loader',
  29. exclude: /node_modules/,
  30. include: path.join(__dirname, './src'),
  31. },
  32. {
  33. test: /\.(png|jpg|gif|svg)$/,
  34. loader: 'file-loader',
  35. options: {
  36. name: '[name].[ext]?[hash]',
  37. publicPath: `../${projectName}`,
  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: `../${projectName}`,
  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 CopyWebpackPlugin([
  80. {
  81. from: path.resolve(__dirname, './static'),
  82. to: __dirname+'/release',
  83. ignore: ['.*']
  84. }
  85. ]),
  86. new VueLoaderPlugin()
  87. ],
  88. devServer: {
  89. // host:'192.168.40.203',
  90. contentBase: './release',
  91. historyApiFallback: true,
  92. watchOptions: { aggregateTimeout: 300, poll: 1000 },
  93. headers: {
  94. "Access-Control-Allow-Origin": "*",
  95. "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
  96. "Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
  97. },
  98. // Proxy config for development purposes. In production, you would configure you webserver to do something similar.
  99. proxy: {
  100. // "/grainReserves": {
  101. // target: "http://localhost:9004",
  102. // pathRewrite: { "^/grainReserves": "" },
  103. // },
  104. // "/myuser": {
  105. // target: "http://218.241.206.66:8097/myuser",
  106. // pathRewrite: {"^/myuser" : ""},
  107. // },
  108. // "/myuser": {
  109. // target: "http://192.168.80.230:8097/myuser",
  110. // pathRewrite: { "^/myuser": "" },
  111. // },
  112. '/api': {
  113. target: 'http://lswz:9090/api', //
  114. secure: false, // 如果是https接口,需要配置这个参数
  115. changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
  116. pathRewrite: {
  117. '^/api': ''
  118. }
  119. },
  120. },
  121. }
  122. };