Skip to content

Commit 811d056

Browse files
committed
feat: initialize project with corresponding CSS pre-processor (close #930)
1 parent 1b85cdf commit 811d056

File tree

2 files changed

+73
-3
lines changed

2 files changed

+73
-3
lines changed

packages/@vue/cli-service/generator/template/src/App.vue

+46-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ export default {
2828
</template>
2929
<%_ } _%>
3030

31-
<style>
31+
<%_ if (rootOptions.cssPreprocessor !== 'stylus') { _%>
32+
<style<%-
33+
rootOptions.cssPreprocessor
34+
? ` lang="${
35+
rootOptions.cssPreprocessor === 'sass'
36+
? 'scss'
37+
: rootOptions.cssPreprocessor
38+
}"`
39+
: ``
40+
%>>
3241
#app {
3342
font-family: 'Avenir', Helvetica, Arial, sans-serif;
3443
-webkit-font-smoothing: antialiased;
@@ -40,7 +49,7 @@ export default {
4049
<%_ } _%>
4150
}
4251
<%_ if (rootOptions.router) { _%>
43-
52+
<%_ if (!rootOptions.cssPreprocessor) { _%>
4453
#nav {
4554
padding: 30px;
4655
}
@@ -53,5 +62,40 @@ export default {
5362
#nav a.router-link-exact-active {
5463
color: #42b983;
5564
}
65+
<%_ } else { _%>
66+
#nav {
67+
padding: 30px;
68+
a {
69+
font-weight: bold;
70+
color: #2c3e50;
71+
&.router-link-exact-active {
72+
color: #42b983;
73+
}
74+
}
75+
}
76+
<%_ } _%>
77+
<%_ } _%>
78+
</style>
79+
<%_ } else { _%>
80+
<style lang="stylus">
81+
#app
82+
font-family 'Avenir', Helvetica, Arial, sans-serif
83+
-webkit-font-smoothing antialiased
84+
-moz-osx-font-smoothing grayscale
85+
text-align center
86+
color #2c3e50
87+
<%_ if (!rootOptions.router) { _%>
88+
margin-top 60px
89+
<%_ } _%>
90+
<%_ if (rootOptions.router) { _%>
91+
92+
#nav
93+
padding 30px
94+
a
95+
font-weight bold
96+
color #2c3e50
97+
&.router-link-exact-active
98+
color #42b983
5699
<%_ } _%>
57100
</style>
101+
<%_ } _%>

packages/@vue/cli-service/generator/template/src/components/HelloWorld.vue

+27-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ export default {
4040
</script>
4141

4242
<!-- Add "scoped" attribute to limit CSS to this component only -->
43-
<style scoped>
43+
<%_ if (rootOptions.cssPreprocessor !== 'stylus') { _%>
44+
<style scoped<%-
45+
rootOptions.cssPreprocessor
46+
? ` lang="${
47+
rootOptions.cssPreprocessor === 'sass'
48+
? 'scss'
49+
: rootOptions.cssPreprocessor
50+
}"`
51+
: ``
52+
%>>
4453
h3 {
4554
margin: 40px 0 0;
4655
}
@@ -56,3 +65,20 @@ a {
5665
color: #42b983;
5766
}
5867
</style>
68+
<%_ } else { _%>
69+
<style scoped lang="stylus">
70+
h3
71+
margin 40px 0 0
72+
73+
ul
74+
list-style-type none
75+
padding 0
76+
77+
li
78+
display inline-block
79+
margin 0 10px
80+
81+
a
82+
color #42b983
83+
</style>
84+
<%_ } _%>

0 commit comments

Comments
 (0)