mirror of https://github.com/sveltejs/svelte
parent
1c241dd1a8
commit
3830216b16
@ -1,22 +0,0 @@
|
||||
import MagicString from 'magic-string';
|
||||
import { magic_string_preprocessor_result } from '../../helpers';
|
||||
|
||||
export default {
|
||||
js_map_sources: [
|
||||
'input.svelte'
|
||||
],
|
||||
preprocess: [
|
||||
{
|
||||
script: ({ content, filename }) => {
|
||||
const s = new MagicString(content);
|
||||
s.prepend('// This script code is approved\n');
|
||||
return magic_string_preprocessor_result(filename, s);
|
||||
},
|
||||
style: ({ content, filename }) => {
|
||||
const s = new MagicString(content);
|
||||
s.prepend('/* This style code is approved */\n');
|
||||
return magic_string_preprocessor_result(filename, s);
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
@ -1,19 +0,0 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let count = 0;
|
||||
|
||||
onMount(() => {
|
||||
const id = setInterval(() => count++, 1000);
|
||||
return () => clearInterval(id);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
h1 {
|
||||
color: orange;
|
||||
}
|
||||
</style>
|
||||
|
||||
<h1>Hello world!</h1>
|
||||
<div>Counter value: {count}</div>
|
@ -1,9 +0,0 @@
|
||||
import { assert_mapped } from '../../helpers';
|
||||
|
||||
export function test({ input, preprocessed }) {
|
||||
assert_mapped({
|
||||
code: '<h1>Hello world!</h1>',
|
||||
input: input.locate,
|
||||
preprocessed
|
||||
});
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
import { magic_string_bundle } from '../../helpers';
|
||||
|
||||
export const EXTERNAL = 'span { --external-var: 1px; }';
|
||||
|
||||
export default {
|
||||
js_map_sources: [],
|
||||
css_map_sources: ['input.svelte', 'external.css'],
|
||||
preprocess: [
|
||||
{
|
||||
style: ({ content, filename }) => {
|
||||
return magic_string_bundle([
|
||||
{ code: EXTERNAL, filename: 'external.css' },
|
||||
{ code: content, filename }
|
||||
]);
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
// This block is here to offset style block
|
||||
</script>
|
||||
|
||||
<style>
|
||||
div { --component-var: 2px; }
|
||||
</style>
|
||||
|
||||
<div><span>Text</span></div>
|
@ -0,0 +1,19 @@
|
||||
import { assert_mapped } from '../../helpers';
|
||||
import { EXTERNAL } from './_config';
|
||||
|
||||
export function test({ input, preprocessed }) {
|
||||
// Part from component, should be with offset
|
||||
assert_mapped({
|
||||
code: '--component-var',
|
||||
input: input.locate,
|
||||
preprocessed
|
||||
});
|
||||
|
||||
// Part from external file, should be without offset
|
||||
assert_mapped({
|
||||
filename: 'external.css',
|
||||
code: '--external-var',
|
||||
input: EXTERNAL,
|
||||
preprocessed
|
||||
});
|
||||
}
|
Loading…
Reference in new issue