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

fix(vuetransfomer): fix unknown asset language for vue scripts/templa… #7056

Merged
merged 6 commits into from Oct 15, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,3 @@
<template src="./main.pug"></template>
<style src="./style.scss"></style>
<script src="./script.ts"></script>
@@ -0,0 +1,5 @@
div
h1 foo
h2 bar
div.box
p {{ msg }}
@@ -0,0 +1,7 @@
export default {
data () {
return {
msg: 'Hello World'
}
}
}
@@ -0,0 +1,24 @@
$cool-color: #c0ff33;

div {
h1 {
color: red;
}
}

h2 {
color: blue;

&:hover {
color: $cool-color;
}
}

.box {
border: 1px solid black;

p {
color: $cool-color;
font-size: 10rem;
}
}
15 changes: 15 additions & 0 deletions packages/core/integration-tests/test/vue.js
Expand Up @@ -105,4 +105,19 @@ describe('vue', function() {
assert.equal(typeof output.render, 'function');
assert.deepEqual(output.data(), {msg: 'Hello from Component A!'});
});
it('should load external templates/styles/scripts properly', async function() {
let b = await bundle(
path.join(__dirname, '/integration/vue-external-files/App.vue'),
);
let output = (await run(b)).default;
assert.equal(typeof output.render, 'function');
assert.deepEqual(output.data(), {msg: 'Hello World'});
let contents = await outputFS.readFile(
path.join(distDir, 'App.css'),
'utf8',
);
assert(contents.includes('color: #c0ff33'));
assert(contents.includes('h2:hover'));
assert(contents.includes('.box p'));
});
});
6 changes: 3 additions & 3 deletions packages/transformers/vue/src/VueTransformer.js
Expand Up @@ -207,7 +207,7 @@ async function processPipeline({
await resolve(asset.filePath, template.src),
)
).toString();
template.lang = extname(template.src);
template.lang = extname(template.src).slice(1);
}
let content = template.content;
if (template.lang && !['htm', 'html'].includes(template.lang)) {
Expand Down Expand Up @@ -267,7 +267,7 @@ ${
await resolve(asset.filePath, script.src),
)
).toString();
script.lang = extname(script.src);
script.lang = extname(script.src).slice(1);
}
let type;
switch (script.lang || 'js') {
Expand Down Expand Up @@ -323,7 +323,7 @@ ${
if (!style.module) {
style.module = MODULE_BY_NAME_RE.test(style.src);
}
style.lang = extname(style.src);
style.lang = extname(style.src).slice(1);
}
switch (style.lang) {
case 'less':
Expand Down