Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(service): synchronous webpack.config.js
- Loading branch information
Guillaume Chau
committed
Nov 2, 2019
1 parent
857bf0c
commit f8b1d46
Showing
3 changed files
with
29 additions
and
0 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
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
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,25 @@ | ||
// this file is for cases where we need to access the | ||
// webpack config as a file when using CLI commands. | ||
|
||
const deasync = require('deasync') | ||
|
||
async function resolve (cb) { | ||
try { | ||
/** @type {import('./src/lib/Service')} */ | ||
let service = process.NODEPACK_SERVICE | ||
|
||
if (!service || process.env.NODEPACK_API_MODE) { | ||
const Service = require('./src/lib/Service') | ||
service = new Service(process.env.NODEPACK_CONTEXT || process.cwd()) | ||
await service.init(process.env.NODEPACK_ENV || process.env.NODE_ENV || 'development') | ||
} | ||
|
||
const config = await service.resolveWebpackConfig() | ||
cb(null, config) | ||
} catch (e) { | ||
cb(e, null) | ||
} | ||
} | ||
|
||
const resolveWebpackConfig = deasync(resolve) | ||
module.exports = resolveWebpackConfig() |