Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: suport env replacement #21

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions crates/loader_compilation/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![feature(box_patterns)]
use std::{path::Path, collections::HashMap, sync::Mutex};
use lazy_static::lazy_static;
use rspack_ast::RspackAst;
Expand Down Expand Up @@ -163,8 +164,10 @@ impl Loader<LoaderRunnerContext> for CompilationLoader {
if routes_config.is_none() || file_accessed {
// Load routes config for transform.
let routes_config_path: std::path::PathBuf = Path::new(compiler_context).join(".ice/route-manifest.json");
*routes_config = Some(load_routes_config(&routes_config_path).unwrap());

let routes_content = load_routes_config(&routes_config_path);
if routes_content.is_ok() {
*routes_config = Some(routes_content?);
}
if file_accessed {
// If file accessed, then we need to clear the map for the current compilation.
file_access.clear();
Expand All @@ -175,7 +178,7 @@ impl Loader<LoaderRunnerContext> for CompilationLoader {
let built = compiler.parse(None, |_| {
transform(
&resource_path,
routes_config.as_ref().unwrap(),
routes_config.as_ref(),
transform_options
)
})?;
Expand Down
Loading