webpack.dev.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. const fs = require('fs');
  4. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  5. const { VueLoaderPlugin } = require('vue-loader');
  6. const HtmlWebpackPlugin = require('html-webpack-plugin');
  7. const ESLintPlugin = require('eslint-webpack-plugin');
  8. const WebpackMerge = require('webpack-merge');
  9. const baseConfig = require('./webpack.base.js');
  10. const { name } = require('./package');
  11. module.exports = WebpackMerge.merge(baseConfig, {
  12. mode: 'development',
  13. //开发环境下默认启用cache,在内存中对已经构建的部分进行缓存
  14. //避免其他模块修改,但是该模块未修改时候,重新构建,能够更快的进行增量构建
  15. //属于空间换时间的做法
  16. cache: true,
  17. // 代码入口
  18. entry: {
  19. // 注册界面
  20. main: './src/main.js',
  21. },
  22. // output: {
  23. // path: path.resolve(__dirname, '../dist'),
  24. // publicPath: '/',
  25. // filename: 'client-role-v3-[name].js',
  26. // chunkFilename: 'client-role-v3-chunk-[name].js',
  27. // },
  28. output: {
  29. publicPath: '/',
  30. library: `${name}-[name]`,
  31. libraryTarget: 'umd', // 把微应用打包成 umd 库格式
  32. // chunkLoadingGlobal: `webpackJsonp_${name}`,
  33. chunkFilename: 'chunk/client-wms-board-chunk-[name].js',
  34. },
  35. devServer: {
  36. port: 8089,
  37. // static: {
  38. // directory: path.join(__dirname, ''),
  39. // },
  40. proxy: {
  41. '/api': {
  42. target: 'http://192.168.1.7:10026/',
  43. ws: false,
  44. changeOrigin: true,
  45. },
  46. '/authApi': {
  47. target: 'http://192.168.1.7:10026/',
  48. ws: false,
  49. changeOrigin: true,
  50. },
  51. '/android-device-sdk': {
  52. target: 'http://192.168.1.7:10026/',
  53. ws: false,
  54. changeOrigin: true,
  55. },
  56. },
  57. headers: {
  58. 'Access-Control-Allow-Origin': '*',
  59. },
  60. },
  61. devtool: 'source-map',
  62. plugins: (module.exports.plugins || []).concat([
  63. new webpack.DefinePlugin({
  64. 'process.env.APP_ENV': JSON.stringify('development'),
  65. }),
  66. new HtmlWebpackPlugin({
  67. title: 'client-div-v3',
  68. template: './public/index.html', // 源模板文件
  69. filename: './index.html', // 输出文件【注意:这里的根路径是module.exports.output.path】
  70. chunks: ['main'],
  71. }),
  72. ]),
  73. });