-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support for
import.meta.env.MODE
(#3168)
- Loading branch information
1 parent
d50a5a6
commit c26edc1
Showing
17 changed files
with
173 additions
and
24 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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,47 @@ | ||
import { build } from '@e2e/helper'; | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test('should define vars in production mode correctly', async () => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
}); | ||
|
||
const file = await rsbuild.getIndexFile(); | ||
expect(file.content).toContain( | ||
'console.log("import.meta.env.MODE","production")', | ||
); | ||
expect(file.content).not.toContain('console.log("import.meta.env.DEV")'); | ||
expect(file.content).toContain('console.log("import.meta.env.PROD")'); | ||
}); | ||
|
||
test('should define vars in development mode correctly', async () => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
rsbuildConfig: { | ||
mode: 'development', | ||
}, | ||
}); | ||
|
||
const file = await rsbuild.getIndexFile(); | ||
expect(file.content).toContain( | ||
'console.log(\'import.meta.env.MODE\', "development");', | ||
); | ||
expect(file.content).toContain("console.log('import.meta.env.DEV');"); | ||
expect(file.content).not.toContain("console.log('import.meta.env.PROD');"); | ||
}); | ||
|
||
test('should define vars in none mode correctly', async () => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
rsbuildConfig: { | ||
mode: 'none', | ||
}, | ||
}); | ||
|
||
const file = await rsbuild.getIndexFile(); | ||
expect(file.content).toContain( | ||
'console.log(\'import.meta.env.MODE\', "none");', | ||
); | ||
expect(file.content).not.toContain("console.log('import.meta.env.DEV');"); | ||
expect(file.content).not.toContain("console.log('import.meta.env.PROD');"); | ||
}); |
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,7 @@ | ||
console.log('import.meta.env.MODE', import.meta.env.MODE); | ||
if (import.meta.env.DEV) { | ||
console.log('import.meta.env.DEV'); | ||
} | ||
if (import.meta.env.PROD) { | ||
console.log('import.meta.env.PROD'); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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
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