Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Make dev mode reflect changes to css #1439

Merged
merged 1 commit into from
Aug 26, 2020
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
15 changes: 8 additions & 7 deletions src/core/create_compilers/RollupCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class RollupCompiler {
warnings: any[];
errors: any[];
chunks: any[];
css_files: Array<{ id: string; code: string }>;
css_files: Record<string, string>;
dependencies: Record<string, string[]>;

constructor(config: any) {
Expand All @@ -62,7 +62,7 @@ export default class RollupCompiler {
this.warnings = [];
this.errors = [];
this.chunks = [];
this.css_files = [];
this.css_files = {};
this.dependencies = {};
}

Expand All @@ -81,7 +81,7 @@ export default class RollupCompiler {
buildStart(this: PluginContext, options: NormalizedInputOptions): void {
const input = options.input;
const inputs: Array<{alias: string, file: string}> = [];

if (typeof input === 'string') {
inputs.push({alias: 'main', file: input});
} else if (Array.isArray(input)) {
Expand All @@ -99,9 +99,10 @@ export default class RollupCompiler {
that.chunks.push(chunk);
},
transform(code: string, id: string): TransformResult {
// TODO: see if we can remove after release of https://github.com/sveltejs/rollup-plugin-svelte/pull/72
// rollup-plugin-svelte adds an import statement to the js file which references the css file
// that won't be able to be compiled as js, so we remove it here and store a copy to use later
if (/\.css$/.test(id)) {
that.css_files.push({ id, code });
that.css_files[id] = code;
return {code: '', moduleSideEffects: 'no-treeshake'};
}
},
Expand Down Expand Up @@ -137,8 +138,8 @@ export default class RollupCompiler {
output: chunk_content_from_modules(
css_modules,
css_module => {
const f = that.css_files.find(file => file.id === css_module);
return f && extract_sourcemap(f.code, css_module);
const code = that.css_files[css_module];
return code && extract_sourcemap(code, css_module);
}
),
sourcemap_url_prefix: '',
Expand Down
2 changes: 0 additions & 2 deletions src/core/create_compilers/RollupResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default class RollupResult implements CompileResult {
chunks: Chunk[];
assets: Record<string, string>;
dependencies: Record<string, string[]>;
css_files: CssFile[];
sourcemap: boolean | 'inline';
summary: string;

Expand All @@ -31,7 +30,6 @@ export default class RollupResult implements CompileResult {
modules: Object.keys(chunk.modules).map(m => normalize_path(m))
}));

this.css_files = compiler.css_files;
this.dependencies = compiler.dependencies;

this.assets = {};
Expand Down
1 change: 0 additions & 1 deletion src/core/create_compilers/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export interface CompileResult {
warnings: CompileError[];
chunks: Chunk[];
assets: Record<string, string>;
css_files: CssFile[];
print: () => void;

to_json: (manifest_data: ManifestData, dirs: Dirs) => BuildInfo;
Expand Down