增加了对全局crypto,buffer等库的注入

This commit is contained in:
Xu Chang 2022-05-06 19:34:12 +08:00
parent 3f0c282458
commit 213e5c78ac
4 changed files with 10 additions and 1 deletions

View File

@ -73,6 +73,8 @@ module.exports = {
symlinks: true,
fallback: {
crypto: require.resolve('crypto-browserify'),
buffer: require.resolve('safe-buffer'),
stream: require.resolve('stream-browserify'),
},
},
resolveLoader: {
@ -208,6 +210,9 @@ module.exports = {
),
}),
new Dotenv({ path: ENV_CONFIG, silent: true }),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
})
],
watch: true,
watchOptions: {

View File

@ -22,10 +22,12 @@
"@types/node": "^12.0.27",
"@types/shelljs": "^0.8.8",
"@xmldom/xmldom": "^0.8.2",
"stream-browserify": "^3.0.0",
"typescript": "^4.6.3"
},
"dependencies": {
"axios": ">=0.21.1",
"buffer": "^6.0.3",
"chalk": "^4.1.0",
"clean-webpack-plugin": "^4.0.0",
"commander": "^6.0.0",

View File

@ -1,4 +1,6 @@
/**app.wxss**/
@import url("https://fonts.googleapis.com/icon?family=Material+Icons");
.container {
height: 100%;
display: flex;

View File

@ -26,7 +26,7 @@ export const createFeatures = (basicFeatures: BasicFeatures<EntityDict, RuntimeC
const { OakComponent, OakPage, features } = InitializeWechatMp<EntityDict, RuntimeContext, typeof aspectDict, ReturnType<typeof createFeatures>>(
storageSchema,
createFeatures,
(store) => new RuntimeContext(store, data.application[0].id, token.getToken()),
(store, scene) => new RuntimeContext(store, data.application[0].id, () => token.getToken(), scene),
routers,
triggers,
checkers,