Last active
April 13, 2020 14:00
-
-
Save fivethreeo/328a7a64c88375e9af8da85168fbc2ce to your computer and use it in GitHub Desktop.
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
'use strict'; | |
const path = require('path'); | |
const fs = require('fs'); | |
const appDirectory = fs.realpathSync(process.cwd()); | |
const resolveApp = relativePath => path.resolve(appDirectory, relativePath); | |
module.exports = { | |
modify: (defaultConfig, { target, dev }, webpack) => { | |
const config = Object.assign({}, defaultConfig); | |
config.module.rules = config.module.rules.reduce((rules, rule) => { | |
if (rule.test && | |
rule.test.toString()===/\.(js|jsx|mjs)$/.toString() && | |
!rule.enforce) { | |
const { include, ...rest } = rule; | |
rules.push({ ...rest, ...{ | |
include: include.concat([resolveApp('api')]) | |
}}); | |
} | |
else { | |
rules.push(rule); | |
} | |
return rules; | |
}, []); | |
return config; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment