Skip to content

Commit

Permalink
feat: unique content paths for each environment
Browse files Browse the repository at this point in the history
  • Loading branch information
cossssmin committed Dec 16, 2024
1 parent 543ca9e commit 8d9a65f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/utils/getConfigByFilePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ export async function readFileConfig(config) {
}
}

/**
* Override the `content` key in `baseConfig` with the one in `envConfig`.
*
* This is done so that each build uses its own `content` paths, in
* order to avoid compiling unnecessary files.
*/
if (Array.isArray(envConfig.content)) {
baseConfig.content = []
}

return merge(envConfig, baseConfig)
} catch (error) {
throw new Error('Could not compute config')
Expand Down
9 changes: 9 additions & 0 deletions test/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ describe.concurrent('Config', () => {
.toHaveProperty('local', true)
.toHaveProperty('foo', 'bar')
})

test('Overrides `content` in base config', async () => {
const config = await readFileConfig({ env: 'maizzle-ci', content: 'foo' })

expect(config)
.toHaveProperty('env', 'maizzle-ci')
.toHaveProperty('local', true)
.toHaveProperty('content', ['maizzle-ci'])
})
})
3 changes: 2 additions & 1 deletion test/stubs/config/maizzle.config.local.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
local: true
local: true,
content: ['local'],
}
3 changes: 2 additions & 1 deletion test/stubs/config/maizzle.config.maizzle-ci.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
foo: 'bar'
foo: 'bar',
content: ['maizzle-ci'],
}

0 comments on commit 8d9a65f

Please sign in to comment.