Skip to content

Instantly share code, notes, and snippets.

@fivethreeo
Last active April 13, 2020 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fivethreeo/328a7a64c88375e9af8da85168fbc2ce to your computer and use it in GitHub Desktop.
Save fivethreeo/328a7a64c88375e9af8da85168fbc2ce to your computer and use it in GitHub Desktop.
'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