diff --git a/src/utils/getConfigByFilePath.js b/src/utils/getConfigByFilePath.js index 41b43101..caf9d17c 100644 --- a/src/utils/getConfigByFilePath.js +++ b/src/utils/getConfigByFilePath.js @@ -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') diff --git a/test/config.test.js b/test/config.test.js index 0a9122a9..3e724126 100644 --- a/test/config.test.js +++ b/test/config.test.js @@ -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']) + }) }) diff --git a/test/stubs/config/maizzle.config.local.js b/test/stubs/config/maizzle.config.local.js index cc24bc4c..f31b4c45 100644 --- a/test/stubs/config/maizzle.config.local.js +++ b/test/stubs/config/maizzle.config.local.js @@ -1,3 +1,4 @@ export default { - local: true + local: true, + content: ['local'], } diff --git a/test/stubs/config/maizzle.config.maizzle-ci.js b/test/stubs/config/maizzle.config.maizzle-ci.js index 92b33d29..96c6e6a4 100644 --- a/test/stubs/config/maizzle.config.maizzle-ci.js +++ b/test/stubs/config/maizzle.config.maizzle-ci.js @@ -1,3 +1,4 @@ export default { - foo: 'bar' + foo: 'bar', + content: ['maizzle-ci'], }