Commit ef37de3e authored by 郭铭瑶's avatar 郭铭瑶 🤘

定义stylus变量配置

parent c4ee3ed0
...@@ -9,5 +9,12 @@ ...@@ -9,5 +9,12 @@
}], }],
"stage-2" "stage-2"
], ],
"plugins": ["transform-vue-jsx", "transform-runtime"] "plugins": [
"transform-vue-jsx",
"transform-runtime",
["import", {
"libraryName": "view-design",
"libraryDirectory": "src/components"
}]
]
} }
...@@ -54,6 +54,19 @@ exports.cssLoaders = function (options) { ...@@ -54,6 +54,19 @@ exports.cssLoaders = function (options) {
} }
} }
/**
* 下面的stylus配置便于可全局使用stylus定义的变量
*/
const stylusOptions = {
import: [
path.join(__dirname, '../src/assets/css/variables.styl')
],
path: [
path.join(__dirname, '../src/assets'),
path.join(__dirname, '../')
]
}
// https://vue-loader.vuejs.org/en/configurations/extract-css.html // https://vue-loader.vuejs.org/en/configurations/extract-css.html
return { return {
css: generateLoaders(), css: generateLoaders(),
...@@ -61,8 +74,8 @@ exports.cssLoaders = function (options) { ...@@ -61,8 +74,8 @@ exports.cssLoaders = function (options) {
less: generateLoaders('less'), less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }), sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass'), scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'), stylus: generateLoaders('stylus', stylusOptions),
styl: generateLoaders('stylus') styl: generateLoaders('stylus', stylusOptions)
} }
} }
......
...@@ -74,6 +74,14 @@ module.exports = { ...@@ -74,6 +74,14 @@ module.exports = {
limit: 10000, limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]') name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
} }
},
{
test: /\.styl(us)?$/,
use: [
'vue-style-loader',
'css-loader',
'stylus-loader'
]
} }
] ]
}, },
......
This diff is collapsed.
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"countup.js": "^2.0.4", "countup.js": "^2.0.4",
"echarts": "^4.4.0", "echarts": "^4.4.0",
"view-design": "^4.0.2",
"vue": "^2.5.2", "vue": "^2.5.2",
"vue-countup-v2": "^4.0.0", "vue-countup-v2": "^4.0.0",
"vue-router": "^3.0.1" "vue-router": "^3.0.1"
...@@ -24,6 +25,7 @@ ...@@ -24,6 +25,7 @@
"babel-eslint": "^8.2.1", "babel-eslint": "^8.2.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3", "babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1", "babel-loader": "^7.1.1",
"babel-plugin-import": "^1.12.2",
"babel-plugin-syntax-jsx": "^6.18.0", "babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0", "babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0", "babel-plugin-transform-vue-jsx": "^3.5.0",
...@@ -50,6 +52,8 @@ ...@@ -50,6 +52,8 @@
"rimraf": "^2.6.0", "rimraf": "^2.6.0",
"semver": "^5.3.0", "semver": "^5.3.0",
"shelljs": "^0.7.6", "shelljs": "^0.7.6",
"stylus": "^0.54.7",
"stylus-loader": "^3.0.2",
"uglifyjs-webpack-plugin": "^1.1.1", "uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8", "url-loader": "^0.5.8",
"vue-loader": "^13.3.0", "vue-loader": "^13.3.0",
......
...@@ -10,27 +10,25 @@ export default { ...@@ -10,27 +10,25 @@ export default {
} }
</script> </script>
<style> <style lang="stylus">
@font-face { @import './assets/css/variables.styl'
font-family: DIN;
src: url(./assets/font/DIN-Medium.otf); @font-face
} font-family DIN
@font-face { src url(./assets/font/DIN-Medium.otf)
font-family: Microsoft YaHei UI; @font-face
src: url(./assets/font/Microsoft-YaHei-UI-Bold.ttf); font-family Microsoft YaHei UI
} src url(./assets/font/Microsoft-YaHei-UI-Bold.ttf)
html, body { html, body
width: 100%; width 100%
height: 100%; height 100%
user-select: none; user-select none
} #app
#app {
/* font-family: 'Avenir', Helvetica, Arial, sans-serif; */ /* font-family: 'Avenir', Helvetica, Arial, sans-serif; */
font-family: DIN, Microsoft YaHei UI, 'Avenir', Helvetica, Arial, sans-serif; font-family DIN, Microsoft YaHei UI, 'Avenir', Helvetica, Arial, sans-serif
-webkit-font-smoothing: antialiased; -webkit-font-smoothing antialiased
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing grayscale
width: 100%; width 100%
height: 100%; height 100%
color: #2c3e50; color $fontColor
}
</style> </style>
...@@ -95,19 +95,20 @@ export default { ...@@ -95,19 +95,20 @@ export default {
</script> </script>
<!-- Add "scoped" attribute to limit CSS to this component only --> <!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped> <style lang="stylus" scoped>
h1, h2 { $red = gold
font-weight: normal; h1, h2
} font-weight normal
ul { color $red
list-style-type: none; ul
padding: 0; list-style-type none
} padding 0
li { li {
display: inline-block; display: inline-block;
margin: 0 10px; margin: 0 10px;
} }
a { a {
color: #42b983; color: $red;
} }
</style> </style>
...@@ -4,8 +4,11 @@ import 'babel-polyfill' ...@@ -4,8 +4,11 @@ import 'babel-polyfill'
import Vue from 'vue' import Vue from 'vue'
import App from './App' import App from './App'
import router from './router' import router from './router'
import {Button} from 'view-design'
import 'view-design/dist/styles/iview.css'
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.component('Button', Button)
/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({
......
import Vue from 'vue' import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld' import Main from '@/views/main'
Vue.use(Router) Vue.use(Router)
...@@ -8,8 +8,8 @@ export default new Router({ ...@@ -8,8 +8,8 @@ export default new Router({
routes: [ routes: [
{ {
path: '/', path: '/',
name: 'HelloWorld', name: 'main',
component: HelloWorld component: Main
} }
] ]
}) })
<template>
<div class="main-container">
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
<div class="box5"></div>
<div class="box6"></div>
</div>
</template>
<script>
export default {
name: 'Main',
}
</script>
<style lang="stylus" scoped>
.main-container
background $fontColor
width 100%
height 100%
display grid
grid-template-areas \
'box1 box1 box1'\
'box2 box3 box4'\
'box5 box3 box4'\
'box6 box6 box6'
grid-template-rows 1fr 3fr 3fr 1fr
grid-gap 10px
padding 10px
.box1
background red
grid-area box1
.box2
background blue
grid-area box2
.box3
background gold
grid-area box3
.box4
background green
grid-area box4
.box5
background gray
grid-area box5
.box6
background #fff
grid-area box6
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment