webpack.config.js 5.6 KB

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