webpack.config.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* eslint-disable */
  2. const HtmlWebpackPlugin = require("html-webpack-plugin");
  3. const ESLintPlugin = require("eslint-webpack-plugin");
  4. const CopyPlugin = require("copy-webpack-plugin");
  5. const webpack = require("webpack");
  6. const path = require("path");
  7. const appDirectory = path.resolve(__dirname, "./");
  8. const srcDirectory = path.resolve(__dirname, "../src");
  9. const rootDirectory = path.resolve(__dirname, "../../");
  10. const babelLoaderConfiguration = {
  11. test: /\.(tsx|ts|js|jsx)$/,
  12. include: [
  13. path.resolve(appDirectory, "index.tsx"),
  14. path.resolve(srcDirectory, "index.tsx"),
  15. path.resolve(srcDirectory),
  16. path.resolve(rootDirectory, "src"),
  17. path.resolve(rootDirectory, "node_modules/@react-navigation/native-stack"),
  18. path.resolve(rootDirectory, "node_modules/@react-native/new-app-screen"),
  19. path.resolve(rootDirectory, "node_modules/@react-navigation/elements"),
  20. path.resolve(rootDirectory, "node_modules/@react-navigation/native"),
  21. path.resolve(rootDirectory, "node_modules/react-native-uncompiled"),
  22. path.resolve(rootDirectory, "node_modules/lucide-react-native"),
  23. path.resolve(rootDirectory, "node_modules/react-native"),
  24. path.resolve(rootDirectory, "node_modules/expo-font"),
  25. path.resolve(rootDirectory, "node_modules/expo-modules-core"),
  26. path.resolve(rootDirectory, "node_modules/expo-asset")
  27. ],
  28. use: {
  29. loader: "babel-loader",
  30. options: {
  31. cacheDirectory: true,
  32. presets: [
  33. "module:@react-native/babel-preset",
  34. "@babel/preset-typescript"
  35. ],
  36. plugins: [
  37. "react-native-web"
  38. ]
  39. }
  40. }
  41. };
  42. const imageLoaderConfiguration = {
  43. test: /\.(gif|jpe?g|png|svg)$/,
  44. use: {
  45. loader: "url-loader",
  46. options: {
  47. name: "[name].[ext]",
  48. esModule: false
  49. }
  50. }
  51. };
  52. module.exports = {
  53. entry: [
  54. path.resolve(appDirectory, "index.tsx")
  55. ],
  56. mode: "development",
  57. devtool: "source-map",
  58. output: {
  59. path: path.resolve(appDirectory, "dist"),
  60. filename: "bundle.web.js",
  61. publicPath: "/"
  62. },
  63. devServer: {
  64. port: 3000,
  65. historyApiFallback: true,
  66. client: {
  67. logging: "none",
  68. overlay: {
  69. errors: true,
  70. warnings: false
  71. }
  72. }
  73. },
  74. ignoreWarnings: [
  75. {
  76. module: /lucide-react-native/
  77. },
  78. {
  79. module: /@react-navigation/
  80. },
  81. {
  82. module: /ncore-ui-kit/
  83. }
  84. ],
  85. module: {
  86. rules: [
  87. babelLoaderConfiguration,
  88. imageLoaderConfiguration,
  89. {
  90. test: /\.(js|mjs|jsx)$/,
  91. include: [
  92. path.resolve(rootDirectory, "node_modules/@react-navigation")
  93. ],
  94. type: "javascript/auto",
  95. resolve: {
  96. fullySpecified: false
  97. }
  98. },
  99. {
  100. test: /\.mjs$/,
  101. include: /node_modules/,
  102. type: "javascript/auto"
  103. },
  104. {
  105. test: /\.(ttf|otf|eot|woff|woff2)$/,
  106. type: "asset/resource",
  107. generator: {
  108. filename: "../src/assets/fonts/[name][ext]"
  109. }
  110. }
  111. ]
  112. },
  113. plugins: [
  114. new HtmlWebpackPlugin({
  115. template: path.resolve(appDirectory, "./public/index.html"),
  116. filename: "index.html"
  117. }),
  118. new webpack.DefinePlugin({
  119. "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development"),
  120. __DEV__: JSON.stringify(process.env.NODE_ENV !== "production"),
  121. "__REACT_DEVTOOLS_GLOBAL_HOOK__": "({ isDisabled: true })",
  122. "process.env.EXPO_OS": JSON.stringify("web"),
  123. "process.env": JSON.stringify({})
  124. }),
  125. new ESLintPlugin({
  126. overrideConfigFile: path.resolve(rootDirectory, "eslint.config.mjs"),
  127. failOnError: process.env.NODE_ENV === "production",
  128. exclude: [
  129. path.resolve(rootDirectory, "node_modules"),
  130. path.resolve(appDirectory, "dist")
  131. ],
  132. eslintPath: "eslint/use-at-your-own-risk",
  133. configType: "flat",
  134. emitWarning: true,
  135. extensions: [
  136. "tsx",
  137. "jsx",
  138. "ts",
  139. "js"
  140. ]
  141. }),
  142. new CopyPlugin({
  143. patterns: [
  144. {
  145. globOptions: {
  146. ignore: [
  147. "**/index.html"
  148. ]
  149. },
  150. noErrorOnMissing: true,
  151. from: "public",
  152. to: "."
  153. }
  154. ]
  155. })
  156. ],
  157. resolve: {
  158. symlinks: false,
  159. alias: {
  160. "react-native$": "react-native-web",
  161. "ncore-ui-kit": path.resolve(rootDirectory, "src/index")
  162. },
  163. extensions: [
  164. ".web.tsx",
  165. ".web.ts",
  166. ".web.js",
  167. ".tsx",
  168. ".ts",
  169. ".js",
  170. ".mjs"
  171. ],
  172. modules: [
  173. path.resolve(rootDirectory, "node_modules"),
  174. "node_modules"
  175. ]
  176. }
  177. };