webpack.config.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. const path = require("path");
  2. const webpack = require("webpack");
  3. const HtmlWebpackPlugin = require("html-webpack-plugin");
  4. const appDirectory = path.resolve(__dirname, "./");
  5. const rootDirectory = path.resolve(__dirname, "../../");
  6. const babelLoaderConfiguration = {
  7. test: /\.(tsx|ts|js|jsx)$/,
  8. include: [
  9. path.resolve(appDirectory, "index.js"),
  10. path.resolve(appDirectory, "App.tsx"),
  11. path.resolve(appDirectory, "src"),
  12. path.resolve(rootDirectory, "src"),
  13. path.resolve(appDirectory, "node_modules/@react-navigation/native-stack"),
  14. path.resolve(appDirectory, "node_modules/@react-native/new-app-screen"),
  15. path.resolve(appDirectory, "node_modules/@react-navigation/elements"),
  16. path.resolve(appDirectory, "node_modules/@react-navigation/native"),
  17. path.resolve(appDirectory, "node_modules/react-native-uncompiled"),
  18. path.resolve(appDirectory, "node_modules/lucide-react-native"),
  19. path.resolve(appDirectory, "node_modules/react-native")
  20. ],
  21. use: {
  22. loader: "babel-loader",
  23. options: {
  24. cacheDirectory: true,
  25. presets: [
  26. "module:@react-native/babel-preset",
  27. "@babel/preset-typescript"
  28. ],
  29. plugins: [
  30. "react-native-web"
  31. ]
  32. }
  33. }
  34. };
  35. const imageLoaderConfiguration = {
  36. test: /\.(gif|jpe?g|png|svg)$/,
  37. use: {
  38. loader: "url-loader",
  39. options: {
  40. name: "[name].[ext]",
  41. esModule: false
  42. }
  43. }
  44. };
  45. module.exports = {
  46. entry: [
  47. path.resolve(appDirectory, "index.js")
  48. ],
  49. mode: "development",
  50. devtool: "source-map",
  51. output: {
  52. path: path.resolve(appDirectory, "dist"),
  53. filename: "bundle.web.js",
  54. publicPath: "/"
  55. },
  56. devServer: {
  57. port: 3000,
  58. historyApiFallback: true,
  59. client: {
  60. overlay: {
  61. errors: true,
  62. warnings: false
  63. }
  64. }
  65. },
  66. ignoreWarnings: [
  67. {
  68. module: /lucide-react-native/
  69. },
  70. {
  71. module: /@react-navigation/
  72. },
  73. {
  74. module: /ncore-ui-kit-mobile/
  75. }
  76. ],
  77. module: {
  78. rules: [
  79. babelLoaderConfiguration,
  80. imageLoaderConfiguration,
  81. {
  82. test: /\.(js|mjs|jsx)$/,
  83. include: [
  84. path.resolve(appDirectory, "node_modules/@react-navigation")
  85. ],
  86. type: "javascript/auto",
  87. resolve: {
  88. fullySpecified: false
  89. }
  90. },
  91. {
  92. test: /\.mjs$/,
  93. include: /node_modules/,
  94. type: "javascript/auto"
  95. }
  96. ]
  97. },
  98. plugins: [
  99. new HtmlWebpackPlugin({
  100. template: path.resolve(appDirectory, "./public/index.html"),
  101. filename: "index.html"
  102. }),
  103. new webpack.DefinePlugin({
  104. __DEV__: JSON.stringify(process.env.NODE_ENV !== "production"),
  105. })
  106. ],
  107. resolve: {
  108. alias: {
  109. "react-native$": "react-native-web",
  110. "ncore-ui-kit-mobile": path.resolve(rootDirectory, "src/index")
  111. },
  112. extensions: [
  113. ".web.tsx",
  114. ".web.ts",
  115. ".web.js",
  116. ".tsx",
  117. ".ts",
  118. ".js",
  119. ".mjs"
  120. ],
  121. modules: [
  122. path.resolve(appDirectory, "node_modules"),
  123. path.resolve(rootDirectory, "node_modules"),
  124. "node_modules"
  125. ]
  126. }
  127. };