mirror of https://github.com/sveltejs/svelte
parent
3830216b16
commit
20499ee77e
@ -0,0 +1,33 @@
|
|||||||
|
import { magic_string_bundle } from '../../helpers';
|
||||||
|
|
||||||
|
export const component_filepath = 'src/input.svelte';
|
||||||
|
|
||||||
|
export const component_file_basename = 'input.svelte';
|
||||||
|
|
||||||
|
// as output by external tool for src/external_code.css (relative to src/input.svelte)
|
||||||
|
export const external_relative_filename = 'external_code.css';
|
||||||
|
|
||||||
|
const external_code = `
|
||||||
|
span {
|
||||||
|
--external_code-var: 1px;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default {
|
||||||
|
css_map_sources: [external_relative_filename],
|
||||||
|
js_map_sources: [],
|
||||||
|
preprocess: [
|
||||||
|
{
|
||||||
|
style: ({ content, filename }) => {
|
||||||
|
const external =`/* Filename from preprocess: ${filename} */` + external_code;
|
||||||
|
return magic_string_bundle([
|
||||||
|
{ code: external, filename: external_relative_filename },
|
||||||
|
{ code: content, filename }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
options: {
|
||||||
|
filename: component_filepath
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,3 @@
|
|||||||
|
<style src="external_code.css"></style>
|
||||||
|
|
||||||
|
<span>Hello world</span>
|
@ -0,0 +1,15 @@
|
|||||||
|
import { component_filepath, component_file_basename, external_relative_filename } from './_config';
|
||||||
|
|
||||||
|
export function test({ assert, preprocessed }) {
|
||||||
|
assert.notEqual(
|
||||||
|
preprocessed.locate(`/* Filename from preprocess: ${component_filepath} */`),
|
||||||
|
undefined,
|
||||||
|
'Preprocessor should receive same value for filename as passed to preprocess function'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
preprocessed.map.sources.slice().sort(),
|
||||||
|
[external_relative_filename, component_file_basename].sort(),
|
||||||
|
'Preprocessed map should contain sources relative to filepath'
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in new issue