标签:cond code ken condition enc get lock pre exp
require.context: https://webpack.js.org/guides/dependency-management/#requirecontext
require.context(directory, useSubdirectories = true, regExp = /^\.\/.*$/, mode = ‘sync‘);
For example, we have a file for local env called: ‘dev-tools.local.js‘, we want to load it if exists, but don‘t cause any error if file not exists.
const requireDevToolsLocal = require.context( ‘./‘, // look for current dir false, // don‘t look into sub-dir /dev-tools\.local\.js/ // regex filename ) const localFile + requireDevToolsLocal.keys()[0]; // if localfile not exist, don‘t load the file if (local) { requireDevToolsLocal(local) }
[Tools] Using Webpack require.context to conditionally load file
标签:cond code ken condition enc get lock pre exp
原文地址:https://www.cnblogs.com/Answer1215/p/14193702.html