webpack.config.dev.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. const webpack = require('webpack')
  2. const { merge } = require('webpack-merge')
  3. const MiniCssExtractPlugin = require('mini-css-extract-plugin')
  4. const base = require('./webpack.config')
  5. module.exports = merge(base, {
  6. mode: 'development',
  7. // Enable accurate source maps for dev
  8. devtool: 'source-map',
  9. // Load entrypoints without contenthash in filename
  10. output: {
  11. filename: 'js/[name].js',
  12. },
  13. // Load assets without contenthash in filename
  14. module: {
  15. rules: [
  16. {
  17. test: /\.(woff|woff2)$/,
  18. type: 'asset/resource',
  19. generator: {
  20. filename: 'fonts/[name][ext]',
  21. },
  22. },
  23. {
  24. test: /\.(svg|gif|png|jpg|pdf)$/,
  25. type: 'asset/resource',
  26. generator: {
  27. filename: 'images/[name][ext]',
  28. },
  29. },
  30. ],
  31. },
  32. plugins: [
  33. // Extract CSS to a separate file (rather than inlining to a <style> tag)
  34. new MiniCssExtractPlugin({
  35. // Output to public/stylesheets directory
  36. filename: 'stylesheets/[name].css',
  37. }),
  38. // Disable React DevTools if DISABLE_REACT_DEVTOOLS is set to "true"
  39. process.env.DISABLE_REACT_DEVTOOLS === 'true' &&
  40. new webpack.DefinePlugin({
  41. __REACT_DEVTOOLS_GLOBAL_HOOK__: '({ isDisabled: true })',
  42. }),
  43. ].filter(Boolean),
  44. devServer: {
  45. // Expose dev server at www.dev-overleaf.com
  46. host: '0.0.0.0',
  47. port: 3808,
  48. client: {
  49. webSocketURL: 'auto://0.0.0.0:0/ws',
  50. },
  51. allowedHosts: '.dev-overleaf.com',
  52. setupMiddlewares(middlewares, devServer) {
  53. devServer.app.get('/status', (req, res) => res.send('webpack is up'))
  54. return middlewares
  55. },
  56. },
  57. // Customise output to the (node) console
  58. stats: {
  59. colors: true, // Enable some coloured highlighting
  60. // Hide some overly verbose output
  61. performance: false, // Disable as code is uncompressed in dev mode
  62. hash: false,
  63. version: false,
  64. chunks: false,
  65. modules: false,
  66. // Hide copied assets from output
  67. excludeAssets: [/^js\/ace/, /^js\/libs/, /^js\/cmaps/],
  68. },
  69. })