Skip to content

Commit aa0fc5b

Browse files
committed
Added process.browser to DefinePlugin
The idea is that there is no need for passing if (!process.browser) { console.log('hello from server!'); } to the client side bundle. This can also be used for storing server-side-only secrets without leaking it to the client. Although i'm not sure if that's a good idea, because accidentally running the app in `NODE_ENV==development` in "production" would leak all those secrets.
1 parent b8f336c commit aa0fc5b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

server/build/webpack.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ export default async function createCompiler (dir, { dev = false, quiet = false,
112112
filename: 'manifest.js'
113113
}),
114114
new webpack.DefinePlugin({
115-
'process.env.NODE_ENV': JSON.stringify(dev ? 'development' : 'production')
115+
'process.env.NODE_ENV': JSON.stringify(dev ? 'development' : 'production'),
116+
'process.browser': JSON.stringify(true)
116117
}),
117118
new PagesPlugin(),
118119
new CaseSensitivePathPlugin()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy