Skip to content

Commit ef9f345

Browse files
committed
fix(config): 修复setCompile报错
1 parent 2bbe3dc commit ef9f345

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/models/Config.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,20 @@ class Config {
105105
}
106106

107107
// 处理loaders => loader
108-
nextConfig.module.loaders.map((loader, i) => {
109-
if(loader.loaders && !loader.loader) {
110-
loader.loader = loader.loaders.join("!")
111-
}
112-
return loader
113-
})
108+
if(nextConfig.module && nextConfig.module.loaders){
109+
nextConfig.module.loaders.map((loader, i) => {
110+
if(loader.loaders && !loader.loader) {
111+
loader.loader = loader.loaders.join("!")
112+
}
113+
return loader
114+
})
115+
}
116+
114117

115118
// 处理alias
116119
const context = nextConfig.context || this._config.context
117120
const relativeContext = sysPath.relative(this._config.cwd, context)
118-
if(nextConfig.resolve.alias) {
121+
if(nextConfig.resolve && nextConfig.resolve.alias) {
119122
let alias = nextConfig.resolve.alias
120123
Object.keys(alias).map(function(key, i){
121124
alias[key] = sysPath.relative(relativeContext, alias[key])

0 commit comments

Comments
 (0)