aboutsummaryrefslogtreecommitdiff
path: root/src/linker.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/linker.zig')
-rw-r--r--src/linker.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/linker.zig b/src/linker.zig
index f92d0c1a3..0c68d53f1 100644
--- a/src/linker.zig
+++ b/src/linker.zig
@@ -30,6 +30,8 @@ const Runtime = @import("./runtime.zig").Runtime;
pub const CSSResolveError = error{ResolveError};
+pub const OnImportCallback = fn (resolve_result: *const Resolver.Result, import_record: *ImportRecord, source_dir: string) void;
+
pub fn NewLinker(comptime BundlerType: type) type {
return struct {
const HashedFileNameMap = std.AutoHashMap(u64, string);
@@ -46,6 +48,8 @@ pub fn NewLinker(comptime BundlerType: type) type {
runtime_source_path: string,
hashed_filenames: HashedFileNameMap,
+ onImportCSS: ?OnImportCallback = null,
+
pub fn init(
allocator: *std.mem.Allocator,
log: *logger.Log,
@@ -583,6 +587,12 @@ pub fn NewLinker(comptime BundlerType: type) type {
BundlerType.isCacheEnabled and loader == .file,
import_path_format,
);
+
+ if (loader == .css) {
+ if (linker.onImportCSS) |callback| {
+ callback(resolve_result, import_record, source_dir);
+ }
+ }
}
pub fn resolveResultHashKey(linker: *ThisLinker, resolve_result: *const Resolver.Result) string {