Skip to content

Commit c2a78c0

Browse files
authored
Icons work in web for example app (#483)
1 parent 638d98e commit c2a78c0

File tree

9 files changed

+207
-539
lines changed

9 files changed

+207
-539
lines changed

example/babel.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = function (api) {
1414
alias: {
1515
// For development, we want to alias the library to the source
1616
[pak.name]: path.join(__dirname, '..', pak.source),
17-
'react-native-vector-icons': '@expo/vector-icons',
1817
},
1918
},
2019
],

example/package.json

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
11
{
2-
"name": "react-native-paper-dates-example",
3-
"description": "Example app for react-native-paper-dates",
4-
"version": "1.0.0",
5-
"private": true,
6-
"main": "index.js",
7-
"scripts": {
8-
"android": "expo start --android",
9-
"ios": "expo start --ios",
10-
"web": "expo start --web",
11-
"start": "expo start",
12-
"test": "jest"
13-
},
142
"dependencies": {
15-
"crypto-browserify": "^3.12.1",
16-
"expo": "^53.0.10",
3+
"@expo/vector-icons": "^14.0.0",
4+
"expo": "^53.0.11",
5+
"expo-crypto": "^14.1.5",
6+
"expo-font": "^13.3.1",
177
"expo-splash-screen": "~0.30.9",
188
"expo-status-bar": "~2.2.3",
199
"react": "19.0.0",
2010
"react-dom": "19.0.0",
2111
"react-native": "0.79.3",
2212
"react-native-paper": "^5.14.5",
2313
"react-native-safe-area-context": "^5.4.1",
24-
"react-native-web": "~0.20.0",
25-
"stream-browserify": "^3.0.0"
14+
"react-native-web": "~0.20.0"
2615
},
16+
"description": "Example app for react-native-paper-dates",
2717
"devDependencies": {
2818
"@babel/core": "^7.27.4",
2919
"@expo/webpack-config": "^19.0.1",
@@ -45,5 +35,16 @@
4535
"react-native-safe-area-context"
4636
]
4737
}
48-
}
38+
},
39+
"main": "index.js",
40+
"name": "react-native-paper-dates-example",
41+
"private": true,
42+
"scripts": {
43+
"android": "expo start --android",
44+
"ios": "expo start --ios",
45+
"web": "expo start --web",
46+
"start": "expo start",
47+
"test": "jest"
48+
},
49+
"version": "1.0.0"
4950
}

example/webpack.config.js

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const path = require('path')
21
const createExpoWebpackConfigAsync = require('@expo/webpack-config')
2+
const path = require('path')
3+
34
const { resolver } = require('./metro.config')
45

56
const root = path.resolve(__dirname, '..')
@@ -8,25 +9,41 @@ const node_modules = path.join(__dirname, 'node_modules')
89
module.exports = async function (env, argv) {
910
const config = await createExpoWebpackConfigAsync(env, argv)
1011

11-
config.module.rules.push({
12-
test: /\.(js|jsx|ts|tsx)$/,
13-
include: path.resolve(root, 'src'),
14-
use: 'babel-loader',
15-
})
12+
config.entry = path.join(__dirname, 'index.js')
13+
14+
config.module.rules.push(
15+
{
16+
test: /\.(js|ts|tsx)$/,
17+
include: path.resolve(root, 'src'),
18+
use: 'babel-loader',
19+
},
20+
{
21+
test: /\.ttf$/,
22+
loader: 'url-loader', // or directly file-loader
23+
include: path.resolve(
24+
__dirname,
25+
'node_modules/@react-native-vector-icons'
26+
),
27+
}
28+
)
29+
30+
config.ignoreWarnings = [
31+
{
32+
module: /Overlay\.js/,
33+
},
34+
() => true,
35+
]
1636

1737
// We need to make sure that only one version is loaded for peerDependencies
1838
// So we alias them to the versions in example's node_modules
1939
Object.assign(config.resolve.alias, {
2040
...resolver.extraNodeModules,
41+
'crypto': require.resolve('expo-crypto'), //Fixes issue with crypto not being found on web
2142
'react-native-web': path.join(node_modules, 'react-native-web'),
43+
'@react-native-vector-icons/material-design-icons': require.resolve(
44+
'@expo/vector-icons/MaterialCommunityIcons'
45+
),
2246
})
2347

24-
// Add fallback for crypto and stream module
25-
config.resolve.fallback = {
26-
...config.resolve.fallback,
27-
crypto: require.resolve('crypto-browserify'),
28-
stream: require.resolve('stream-browserify'),
29-
}
30-
3148
return config
3249
}

0 commit comments

Comments
 (0)