mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: polyfill Buffer & crypto
This commit is contained in:
@@ -22,10 +22,12 @@
|
||||
"acorn": "^8.0.0",
|
||||
"acorn-stage3": "^4.0.0",
|
||||
"babel-loader": "^8.0.0",
|
||||
"buffer": "^6.0.3",
|
||||
"chalk": "^4.0.0",
|
||||
"cli-highlight": "^2.0.0",
|
||||
"commander": "^7.0.0",
|
||||
"copy-webpack-plugin": "^9.0.0",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"css": "^3.0.0",
|
||||
"css-loader": "^5.0.0",
|
||||
"dotenv-webpack": "^7.0.0",
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
ContextExclusionPlugin,
|
||||
DefinePlugin,
|
||||
HotModuleReplacementPlugin,
|
||||
ProvidePlugin,
|
||||
} from 'webpack';
|
||||
import Config from 'webpack-chain';
|
||||
import { resolve } from 'path';
|
||||
@@ -363,6 +364,18 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
},
|
||||
]);
|
||||
|
||||
// polyfill things that don't exist in the NS runtimes
|
||||
config.plugin('ProvidePlugin|Polyfills').use(ProvidePlugin, [
|
||||
{
|
||||
Buffer: [require.resolve('buffer/'), 'Buffer'],
|
||||
},
|
||||
]);
|
||||
|
||||
config.resolve.set('fallback', {
|
||||
buffer: require.resolve('buffer/'),
|
||||
crypto: require.resolve('crypto-browserify/'),
|
||||
});
|
||||
|
||||
// enable DotEnv
|
||||
applyDotEnvPlugin(config);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user