webpack.config.js 4.2 KB

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