-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #997 from aaronreed708/fix-chroma-problem
#983: exclude cjs from build
- Loading branch information
Showing
3 changed files
with
1,968 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module.exports = { | ||
webpack: { | ||
configure: (config) => { | ||
// ... | ||
const fileLoaderRule = getFileLoaderRule(config.module.rules); | ||
if(!fileLoaderRule) { | ||
throw new Error("File loader not found"); | ||
} | ||
fileLoaderRule.exclude.push(/\.cjs$/); | ||
// ... | ||
return config; | ||
} | ||
} | ||
}; | ||
|
||
function getFileLoaderRule(rules) { | ||
for(const rule of rules) { | ||
if("oneOf" in rule) { | ||
const found = getFileLoaderRule(rule.oneOf); | ||
if(found) { | ||
return found; | ||
} | ||
} else if(rule.test === undefined && rule.type === 'asset/resource') { | ||
return rule; | ||
} | ||
} | ||
} |
Oops, something went wrong.