-
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: skip reading config file with inline option (#317)
- Loading branch information
Showing
9 changed files
with
43 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/vite-plugin-svelte': minor | ||
--- | ||
|
||
skip reading default svelte config file with inline option `configFile: false` |
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
34 changes: 25 additions & 9 deletions
34
packages/e2e-tests/configfile-custom/__tests__/configfile-custom.spec.ts
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 |
---|---|---|
@@ -1,16 +1,32 @@ | ||
import { editViteConfig } from 'testUtils'; | ||
import { editViteConfig, isBuild } from '../../testUtils'; | ||
|
||
it('should load default config and work', async () => { | ||
expect(e2eServer.logs.server.out).toContain('default svelte config loaded'); | ||
expect(await page.textContent('h1')).toMatch('Hello world!'); | ||
expect(await page.textContent('#test-child')).toBe('test-child'); | ||
expect(await page.textContent('#dependency-import')).toBe('dependency-import'); | ||
}); | ||
|
||
it('should load custom mjs config and work', async () => { | ||
await editViteConfig((c) => | ||
c.replace('svelte()', `svelte({configFile:'svelte.config.custom.cjs'})`) | ||
); | ||
expect(await page.textContent('h1')).toMatch('Hello world!'); | ||
expect(await page.textContent('#test-child')).toBe('test-child'); | ||
expect(await page.textContent('#dependency-import')).toBe('dependency-import'); | ||
}); | ||
if (!isBuild) { | ||
// editing vite config does not work in build tests, build only runs once | ||
// TODO split into different tests | ||
it('should load custom cjs config and work', async () => { | ||
await editViteConfig((c) => | ||
c.replace(/svelte\([^)]*\)/, `svelte({configFile:'svelte.config.custom.cjs'})`) | ||
); | ||
expect(e2eServer.logs.server.out).toContain('custom svelte config loaded cjs'); | ||
expect(await page.textContent('h1')).toMatch('Hello world!'); | ||
expect(await page.textContent('#test-child')).toBe('test-child'); | ||
expect(await page.textContent('#dependency-import')).toBe('dependency-import'); | ||
}); | ||
|
||
it('should not read default config when explicitly disabled', async () => { | ||
const currentLogPos = e2eServer.logs.server.out.length; | ||
await editViteConfig((c) => c.replace(/svelte\([^)]*\)/, `svelte({configFile: false})`)); | ||
const logsAfterChange = e2eServer.logs.server.out.slice(currentLogPos); | ||
expect(logsAfterChange).not.toContain('default svelte config loaded'); | ||
expect(await page.textContent('h1')).toMatch('Hello world!'); | ||
expect(await page.textContent('#test-child')).toBe('test-child'); | ||
expect(await page.textContent('#dependency-import')).toBe('dependency-import'); | ||
}); | ||
} |
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,2 @@ | ||
console.log('default svelte config loaded') | ||
module.exports = {}; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
console.log('custom svelte config loaded cjs') | ||
module.exports = { | ||
emitCss: false | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
console.log('custom svelte config loaded mjs') | ||
export default { | ||
emitCss: false | ||
} |
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