webpack.dev.config.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. const Webpack = require('webpack')
  2. const path = require('path')
  3. const merge = require('webpack-merge')
  4. const MiniCssExtractPlugin = require('mini-css-extract-plugin')
  5. const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
  6. const { getThemeVariables } = require('antd/dist/theme')
  7. const baseConfig = require('./webpack.config')
  8. const config = merge(baseConfig, {
  9. entry: {
  10. index: path.resolve(__dirname, '../src/index.tsx'),
  11. publicity: path.resolve(__dirname, '../src/publicity.tsx'),
  12. },
  13. output: {
  14. publicPath: '/',
  15. filename: 'static/js/[name].js',
  16. chunkFilename: 'static/js/[name].chunk.js',
  17. path: __dirname + '/dist',
  18. },
  19. devServer: {
  20. contentBase: path.join(__dirname, '../dist'),
  21. disableHostCheck: true,
  22. watchContentBase: false,
  23. host: '127.0.0.1',
  24. port: 61001,
  25. hot: true,
  26. open: true,
  27. inline: true,
  28. historyApiFallback: true,
  29. stats: 'errors-only',
  30. proxy: {
  31. '/api': {
  32. target: 'http://47.108.135.38:61001',
  33. },
  34. },
  35. },
  36. mode: 'development',
  37. devtool: 'cheap-module-eval-source-map',
  38. module: {
  39. rules: [
  40. {
  41. test: /\.less$/,
  42. use: [
  43. {
  44. loader: 'style-loader',
  45. },
  46. {
  47. loader: 'css-loader', // translates CSS into CommonJS
  48. },
  49. {
  50. loader: 'less-loader', // compiles Less to CSS
  51. options: {
  52. lessOptions: {
  53. javascriptEnabled: true,
  54. },
  55. },
  56. },
  57. ],
  58. },
  59. {
  60. test: /\.scss$/i,
  61. use: ['style-loader', 'css-loader', 'sass-loader'],
  62. exclude: path.resolve(__dirname, '../node_modules'),
  63. },
  64. {
  65. test: /\.css$/i,
  66. use: ['style-loader', 'css-loader'],
  67. },
  68. ],
  69. },
  70. plugins: [
  71. new ForkTsCheckerWebpackPlugin({
  72. async: false,
  73. silent: false,
  74. useTypescriptIncrementalApi: false,
  75. checkSyntacticErrors: true,
  76. formatter: undefined,
  77. }),
  78. new Webpack.HotModuleReplacementPlugin(),
  79. new Webpack.DefinePlugin({
  80. 'process.env.NODE_ENV': JSON.stringify('development'),
  81. }),
  82. new MiniCssExtractPlugin({
  83. filename: 'css/[name].css',
  84. chunkFilename: 'css/[name].css',
  85. }),
  86. ],
  87. })
  88. module.exports = config