è¿äºé项å¯ä»¥é ç½®æ¯å¦ polyfill æ mock æäº Node.js å ¨å±åéã
æ¤åè½ç± webpack å
é¨ç NodeStuffPlugin
æ件æä¾ã
boolean: false
object
webpack.config.js
module.exports = {
//...
node: {
global: false,
__filename: false,
__dirname: false,
},
};
ä» webpack 3.0.0 å¼å§ï¼node
é项å¯è½è¢«è®¾ç½®ä¸º false
ï¼ä»¥å®å
¨å
³é NodeStuffPlugin
æ件ã
boolean
'warn'
å ³äºæ¤å¯¹è±¡çåç¡®è¡ä¸ºï¼è¯·æ¥çNode.js ææ¡£ã
é项ï¼
true
: æä¾ polyfill.false
: ä¸æä¾ä»»ä½ polyfillã代ç å¯è½ä¼åºç° ReferenceError
çå´©æºã'warn'
: å½ä½¿ç¨ global
æ¶å±ç¤ºä¸ä¸ªè¦åãboolean
'mock' | 'warn-mock' | 'eval-only'
é项ï¼
true
: è¾å
¥æ件çæ件åï¼æ¯ç¸å¯¹äº context
é项ãfalse
: webpack ä¸ä¼æ´æ¹ __filename
ç代ç ãå¨ Node.js ç¯å¢ä¸è¿è¡æ¶ï¼åºæ件çæ件åã'mock'
: value å¡«å
为 'index.js'
ã'warn-mock'
: ä½¿ç¨ '/index.js'
ä½æ¯ä¼å±ç¤ºä¸ä¸ªè¦åã'eval-only'
boolean
'mock' | 'warn-mock' | 'eval-only'
é项ï¼
true
: è¾å
¥ æ件çç®å½åï¼æ¯ç¸å¯¹äº context
é项ãfalse
: webpack ä¸ä¼æ´æ¹ __dirname
ç代ç ï¼è¿æå³çä½ æå¸¸è§ Node.js ä¸ç __dirname
çè¡ä¸ºãå¨ Node.js ç¯å¢ä¸è¿è¡æ¶ï¼è¾åº æ件çç®å½åã'mock'
: value å¡«å
为 '/'
ã'warn-mock'
: ä½¿ç¨ '/'
ä½æ¯ä¼æ¾ç¤ºä¸ä¸ªè¦åã'eval-only'