Skip to content

Commit 93f6e47

Browse files
committed
styles are working. looking for a better solution
1 parent 3f14c3e commit 93f6e47

File tree

8 files changed

+21
-57
lines changed

8 files changed

+21
-57
lines changed

.vscode/launch.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
// Hover to view descriptions of existing attributes.
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
6-
"configurations": [{
6+
"configurations": [
7+
8+
{
79
"name": "Attach to Process",
810
"type": "node",
911
"request": "attach",
1012
"port": 9229,
1113
"protocol": "inspector",
12-
"restart": true
14+
"restart": true,
15+
"outFiles": ["${workspaceRoot}/lib"],
16+
"sourceMaps": true
1317
},
1418
{
1519
"type": "node",

example/components/uuid.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div>
33
<inner></inner>
4-
<h2>Uuid: {{uuid ? uuid : 'no uuid'}}</h2>
4+
<h2 class="test">Uuid: {{uuid ? uuid : 'no uuid'}}</h2>
55
</div>
66
</template>
77

example/components/uuid2.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div>
3-
<h3>Uuid2: {{uuid2 ? uuid2 : 'no uuid'}}</h3>
3+
<h3 class="red">Uuid2: {{uuid2 ? uuid2 : 'no uuid'}}</h3>
44
</div>
55
</template>
66

@@ -14,7 +14,7 @@ export default {
1414
</script>
1515

1616
<style lang="css">
17-
.test {
18-
color: blue;
17+
.red {
18+
color: yellowgreen;
1919
}
2020
</style>

example/vueFiles/components/uuid.vue

Lines changed: 0 additions & 20 deletions
This file was deleted.

example/vueFiles/components/uuid2.vue

Lines changed: 0 additions & 20 deletions
This file was deleted.

example/vueFiles/mixins/exampleMixin.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/parser/component.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function componentParser(templatePath: string, defaults: Object, type: string, C
1616
scriptParser(cachedComponentContentObject.parsedContent.script, defaults, type, Cache).then(parsedScriptObject => {
1717
cachedComponentContentObject.script = parsedScriptObject;
1818
cachedComponentContentObject.script.template = cachedComponentContentObject.template;
19+
cachedComponentContentObject.styles = parsedScriptObject.styles;
1920
resolve(cachedComponentContentObject);
2021
}).catch(error => {
2122
reject(error);
@@ -64,7 +65,13 @@ function parseContent(content: string, templatePath: string, defaults: Object, t
6465
Promise.all(promiseArray).then(resultsArray => {
6566
const template = resultsArray[0];
6667
const script = resultsArray[1];
67-
const style = resultsArray[2];
68+
// console.log(resultsArray[2]);
69+
let style = '';
70+
if (resultsArray[2]) {
71+
style = resultsArray[2];
72+
} else {
73+
style = resultsArray[1].styles ? resultsArray[1].styles : '';
74+
}
6875

6976
script.template = template;
7077

src/utils/require.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,17 @@ function requireFromString(code: string, filename: string = '', optsObj: Object
104104
}
105105
Promise.all(promiseArray)
106106
.then(renderedItemArray => {
107+
let styles = '';
107108
for (var renderedItem of renderedItemArray) {
108109
const rawString = renderedItem.rendered.scriptStringRaw;
109110
code = code.replace(renderedItem.match, rawString);
111+
styles += renderedItem.rendered.layout.style;
110112
}
111113
//check if its the last element and then render
112114
const last_element = code.match(options.vueFileRegex);
113115
if (last_element === undefined || last_element === null) {
114116
m._compile(code, filename);
117+
m.exports.default.styles = styles;
115118
resolve(m.exports.default);
116119
}
117120
})

0 commit comments

Comments
 (0)