UNPKG

601 BJavaScriptView Raw
1const fs = require('fs-extra')
2
3// Poor man hot reload template for the app entry.
4// Ideally, this fallback should be handled by webpack.
5// However, at the moment there is no way to disable warning emitted by
6// require.resolve('#app-entry') when the entry module does not exist.
7//
8// See discussion in https://github.com/ream/ream/pull/96
9
10module.exports = api => {
11 if (
12 !(
13 api.config.entry &&
14 fs.pathExistsSync(api.resolveBaseDir(api.config.entry))
15 )
16 ) {
17 return `export default () => ({})`
18 }
19
20 return `
21 import entry from '#app-entry'
22 export default entry
23 `
24}