Няма описание

webpack.config.dev.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. const webpack = require('webpack');
  2. const path = require('path');
  3. const DashboardPlugin = require('webpack-dashboard/plugin');
  4. const baseConfig = require('./webpack.config.base');
  5. const config = {
  6. ...baseConfig,
  7. mode: 'development',
  8. devtool: 'source-map',
  9. plugins: [
  10. ...baseConfig.plugins,
  11. // 在控制台中输出可读的模块名
  12. new webpack.NamedModulesPlugin(),
  13. // 避免发出包含错误的模块
  14. new webpack.NoEmitOnErrorsPlugin(),
  15. // 定义控制变量
  16. new webpack.DefinePlugin({
  17. isProd: JSON.stringify(false)
  18. }),
  19. new DashboardPlugin()
  20. ],
  21. devServer: {
  22. allowedHosts: ['0.0.0.0:8081'],
  23. // 设置生成的 Bundle 的前缀路径
  24. publicPath: '/',
  25. // assets 中资源文件默认应该还使用 assets
  26. contentBase: path.resolve(__dirname, '../../public'),
  27. compress: true,
  28. headers: {
  29. 'Access-Control-Allow-Origin': '*',
  30. 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
  31. 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
  32. 'X-Content-Type-Options': 'nosniff',
  33. 'X-Frame-Options': 'DENY'
  34. },
  35. open: true,
  36. overlay: {
  37. warnings: true,
  38. errors: true
  39. },
  40. host: '0.0.0.0',
  41. port: 8080,
  42. hot: false,
  43. https: false,
  44. disableHostCheck: true,
  45. quiet: false
  46. },
  47. stats: {
  48. children: false
  49. }
  50. };
  51. delete config.extra;
  52. module.exports = config;