cycold / cycold.github.io

Please dot not star...
4 stars 1 forks source link

webpack 按条件导入文件 不是运行时动态导入import() 而是编译时判断条件导入 #154

Closed cycold closed 6 years ago

cycold commented 6 years ago

类似c语言中的宏 https://gcc.gnu.org/onlinedocs/gcc-3.0.2/cpp_4.html

https://stackoverflow.com/questions/36367532/how-can-i-conditionally-import-an-es6-module

似乎使用require就可以

if (true) {
   require('./config.js')
}

https://github.com/caiogondim/webpack-conditional-loader https://github.com/dearrrfish/preprocess-loader https://github.com/nippur72/ifdef-loader