diff --git a/packages/http/src/build/neutrino/targets.js b/packages/http/src/build/neutrino/targets.js index 8964e3f..d037ad5 100644 --- a/packages/http/src/build/neutrino/targets.js +++ b/packages/http/src/build/neutrino/targets.js @@ -22,6 +22,8 @@ module.exports = () => (neutrino) => { join(process.cwd(), 'node_modules'), 'node_modules', ]); + neutrino.options.appRoot = neutrino.options.root; + neutrino.options.appSource = join(neutrino.options.appRoot, 'src'); const root = join(__dirname, '..', '..'); neutrino.options.root = fs.realpathSync(root); neutrino.options.source = 'client'; diff --git a/packages/react/src/build/http.js b/packages/react/src/build/http.js index 030e796..a79fa95 100644 --- a/packages/react/src/build/http.js +++ b/packages/react/src/build/http.js @@ -1,9 +1,9 @@ const react = require('./react'); -module.exports = (config) => { +module.exports = (config, latus) => { const webIndex = config.use.findIndex((m) => m.isWebMiddleware); if (-1 !== webIndex) { - config.use.splice(webIndex, 1, react()); + config.use.splice(webIndex, 1, react(latus)); } config.use.push((neutrino) => { [ diff --git a/packages/react/src/build/react.js b/packages/react/src/build/react.js index 7bce85a..3457ba9 100644 --- a/packages/react/src/build/react.js +++ b/packages/react/src/build/react.js @@ -1,4 +1,8 @@ -const {dirname} = require('path'); +const { + dirname, + isAbsolute, + join, +} = require('path'); const {require: R} = require('@latus/core'); const react = require('@neutrinojs/react'); @@ -9,7 +13,7 @@ const { LATUS_POSTCSS_CONFIG = resolve('@latus/build/build/postcss.config.js'), } = process.env; -module.exports = () => (neutrino) => { +module.exports = (latus) => (neutrino) => { react({ babel: { configFile: LATUS_BABEL_CONFIG, @@ -43,5 +47,12 @@ module.exports = () => (neutrino) => { ], }, })(neutrino); - neutrino.config.module.rule('compile').include.add(`${process.cwd()}/src`); + const {entry} = latus.get('@latus/react'); + neutrino.config.module + .rule('compile').include + .add( + isAbsolute(entry) + ? entry + : join(neutrino.options.appSource, entry), + ); }; diff --git a/packages/react/src/server.js b/packages/react/src/server.js index 71ec890..9a1e63e 100644 --- a/packages/react/src/server.js +++ b/packages/react/src/server.js @@ -2,8 +2,8 @@ const httpBuild = require('./build/http'); export default { hooks: { - '@latus/http/build': (config) => { - httpBuild(config); + '@latus/http/build': (config, latus) => { + httpBuild(config, latus); }, '@latus/http/plugins': (req, { config: {'@latus/react': {entry}},