webpack.config.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. errors: true,
  71. warnings: false
  72. }
  73. }
  74. },
  75. ignoreWarnings: [
  76. {
  77. module: /lucide-react-native/
  78. },
  79. {
  80. module: /@react-navigation/
  81. },
  82. {
  83. module: /ncore-ui-kit/
  84. }
  85. ],
  86. module: {
  87. rules: [
  88. babelLoaderConfiguration,
  89. imageLoaderConfiguration,
  90. {
  91. test: /\.(js|mjs|jsx)$/,
  92. include: [
  93. path.resolve(rootDirectory, "node_modules/@react-navigation")
  94. ],
  95. type: "javascript/auto",
  96. resolve: {
  97. fullySpecified: false
  98. }
  99. },
  100. {
  101. test: /\.mjs$/,
  102. include: /node_modules/,
  103. type: "javascript/auto"
  104. },
  105. {
  106. test: /\.(ttf|otf|eot|woff|woff2)$/,
  107. type: "asset/resource",
  108. generator: {
  109. filename: "../src/assets/fonts/[name][ext]"
  110. }
  111. }
  112. ]
  113. },
  114. plugins: [
  115. new HtmlWebpackPlugin({
  116. template: path.resolve(appDirectory, "./public/index.html"),
  117. filename: "index.html"
  118. }),
  119. new webpack.DefinePlugin({
  120. "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development"),
  121. __DEV__: JSON.stringify(process.env.NODE_ENV !== "production"),
  122. "__REACT_DEVTOOLS_GLOBAL_HOOK__": "({ isDisabled: true })",
  123. "process.env.EXPO_OS": JSON.stringify("web"),
  124. "process.env": JSON.stringify({})
  125. }),
  126. new ESLintPlugin({
  127. overrideConfigFile: path.resolve(rootDirectory, "eslint.config.mjs"),
  128. failOnError: process.env.NODE_ENV === "production",
  129. exclude: [
  130. path.resolve(rootDirectory, "node_modules"),
  131. path.resolve(appDirectory, "dist")
  132. ],
  133. eslintPath: "eslint/use-at-your-own-risk",
  134. configType: "flat",
  135. emitWarning: true,
  136. extensions: [
  137. "tsx",
  138. "jsx",
  139. "ts",
  140. "js"
  141. ]
  142. }),
  143. new CopyPlugin({
  144. patterns: [
  145. {
  146. globOptions: {
  147. dot: true,
  148. ignore: [
  149. "**/index.html"
  150. ]
  151. },
  152. noErrorOnMissing: true,
  153. from: "public",
  154. to: "."
  155. }
  156. ]
  157. })
  158. ],
  159. resolve: {
  160. symlinks: false,
  161. alias: {
  162. "ncore-ui-kit": path.resolve(rootDirectory, "src/index")
  163. },
  164. modules: [
  165. path.resolve(rootDirectory, "node_modules"),
  166. "node_modules"
  167. ]
  168. }
  169. };
  170. module.exports = withNCoreUIKitWebpack(config, webpack);