webpack.config.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. var config = {
  4. mode: "development",
  5. externals: {
  6. 'react': 'React',
  7. 'react-dom': 'ReactDOM',
  8. },
  9. module: {
  10. rules: [
  11. {
  12. // docs: https://webpack.js.org/configuration/module/#resolvefullyspecified
  13. test: /\.m?js/,
  14. resolve: {
  15. fullySpecified: false,
  16. }
  17. }
  18. ]
  19. },
  20. plugins: [
  21. // fix "process is not defined" error:
  22. new webpack.ProvidePlugin({
  23. process: 'process/browser',
  24. }),
  25. ],
  26. };
  27. var AppConfig = Object.assign({}, config, {
  28. name: "app",
  29. entry: {
  30. main : "./target/main.js",
  31. workers : "./target/workers.js",
  32. },
  33. output: {
  34. path: path.resolve(__dirname, 'static/js'),
  35. filename: '[name]-bundle.js',
  36. clean: false,
  37. chunkLoading: false,
  38. },
  39. });
  40. var MobileConfig = Object.assign({}, config, {
  41. name: "mobile",
  42. entry: {
  43. main : "./target/mobile.js",
  44. workers : "./target/workers.js",
  45. },
  46. output: {
  47. path: path.resolve(__dirname, 'static/mobile/js'),
  48. filename: '[name]-bundle.js',
  49. clean: false,
  50. chunkLoading: false,
  51. },
  52. });
  53. module.exports = [
  54. AppConfig, MobileConfig,
  55. ];