Commit 54dab3c652315f713b26e1204c1ea6476acbe88f
1 parent
12dd15d5
导入公用css
Showing
10 changed files
with
486 additions
and
120 deletions
build/utils.js
... | ... | @@ -60,7 +60,16 @@ exports.cssLoaders = function (options) { |
60 | 60 | postcss: generateLoaders(), |
61 | 61 | less: generateLoaders('less'), |
62 | 62 | sass: generateLoaders('sass', { indentedSyntax: true }), |
63 | - scss: generateLoaders('sass'), | |
63 | + scss: generateLoaders('sass').concat({ | |
64 | + loader: 'sass-resources-loader', | |
65 | + options: { | |
66 | + resources: [ | |
67 | + path.resolve(__dirname,'../src/assets/style/mixin.scss'), | |
68 | + //path.resolve(__dirname,'../src/assets/css/variables.scss') | |
69 | + ] | |
70 | + } | |
71 | + }), | |
72 | + | |
64 | 73 | stylus: generateLoaders('stylus'), |
65 | 74 | styl: generateLoaders('stylus') |
66 | 75 | } | ... | ... |
build/webpack.base.conf.js
... | ... | @@ -64,6 +64,16 @@ module.exports = { |
64 | 64 | limit: 10000, |
65 | 65 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') |
66 | 66 | } |
67 | + }, | |
68 | + { | |
69 | + test: /\.scss$/, | |
70 | + use: [{ | |
71 | + loader: "style-loader" // creates style nodes from JS strings | |
72 | + }, { | |
73 | + loader: "css-loader" // translates CSS into CommonJS | |
74 | + }, { | |
75 | + loader: "sass-loader" // compiles Sass to CSS | |
76 | + }] | |
67 | 77 | } |
68 | 78 | ] |
69 | 79 | }, | ... | ... |
package.json
... | ... | @@ -10,6 +10,9 @@ |
10 | 10 | "build": "node build/build.js" |
11 | 11 | }, |
12 | 12 | "dependencies": { |
13 | + "node-sass": "^4.11.0", | |
14 | + "sass-loader": "^7.1.0", | |
15 | + "sass-resources-loader": "^2.0.0", | |
13 | 16 | "vue": "^2.5.2" |
14 | 17 | }, |
15 | 18 | "devDependencies": { |
... | ... | @@ -24,12 +27,13 @@ |
24 | 27 | "babel-preset-stage-2": "^6.22.0", |
25 | 28 | "chalk": "^2.0.1", |
26 | 29 | "copy-webpack-plugin": "^4.0.1", |
27 | - "css-loader": "^0.28.0", | |
30 | + "css-loader": "^0.28.11", | |
28 | 31 | "extract-text-webpack-plugin": "^3.0.0", |
29 | 32 | "file-loader": "^1.1.4", |
30 | 33 | "friendly-errors-webpack-plugin": "^1.6.1", |
31 | 34 | "html-webpack-plugin": "^2.30.1", |
32 | 35 | "node-notifier": "^5.1.2", |
36 | + "node-sass": "^4.11.0", | |
33 | 37 | "optimize-css-assets-webpack-plugin": "^3.2.0", |
34 | 38 | "ora": "^1.2.0", |
35 | 39 | "portfinder": "^1.0.13", |
... | ... | @@ -37,8 +41,12 @@ |
37 | 41 | "postcss-loader": "^2.0.8", |
38 | 42 | "postcss-url": "^7.2.1", |
39 | 43 | "rimraf": "^2.6.0", |
44 | + "sass-loader": "^7.1.0", | |
40 | 45 | "semver": "^5.3.0", |
41 | 46 | "shelljs": "^0.7.6", |
47 | + "style-loader": "^0.23.1", | |
48 | + "stylus": "^0.54.5", | |
49 | + "stylus-loader": "^3.0.2", | |
42 | 50 | "uglifyjs-webpack-plugin": "^1.1.1", |
43 | 51 | "url-loader": "^0.5.8", |
44 | 52 | "vue-loader": "^13.3.0", | ... | ... |
src/App.vue
1 | 1 | <template> |
2 | 2 | <div id="app"> |
3 | - <img src="./assets/logo.png"> | |
4 | - <HelloWorld/> | |
3 | + <geomagnetism v-if="urlLink ===1"/> | |
4 | + <screen v-if="urlLink ===2"/> | |
5 | 5 | </div> |
6 | 6 | </template> |
7 | 7 | |
8 | 8 | <script> |
9 | -import HelloWorld from './components/HelloWorld' | |
9 | +import geomagnetism from './components/geomagnetism' | |
10 | +import screen from './components/screen' | |
10 | 11 | |
11 | 12 | export default { |
12 | 13 | name: 'App', |
13 | 14 | components: { |
14 | - HelloWorld | |
15 | + geomagnetism, screen | |
16 | + }, | |
17 | + data() { | |
18 | + return { | |
19 | + urlLink: '' | |
20 | + } | |
21 | + }, | |
22 | + created() { | |
23 | + this.urlLink = 1 | |
15 | 24 | } |
16 | 25 | } |
17 | 26 | </script> |
... | ... | @@ -23,6 +32,5 @@ export default { |
23 | 32 | -moz-osx-font-smoothing: grayscale; |
24 | 33 | text-align: center; |
25 | 34 | color: #2c3e50; |
26 | - margin-top: 60px; | |
27 | 35 | } |
28 | 36 | </style> | ... | ... |
src/assets/style/mixin.scss
0 → 100644
1 | + | |
2 | +//清楚浮动 | |
3 | +@mixin clearfix() { | |
4 | + &:before, | |
5 | + &:after { | |
6 | + content: ""; | |
7 | + display: table; | |
8 | + } | |
9 | + &:after { | |
10 | + clear: both; | |
11 | + } | |
12 | +} | |
13 | + | |
14 | +//圆角边框 | |
15 | +@mixin border-radius($radius) { | |
16 | + -webkit-border-radius: $radius; | |
17 | + -moz-border-radius: $radius; | |
18 | + -ms-border-radius: $radius; | |
19 | + border-radius: $radius; | |
20 | +} | |
21 | + | |
22 | +// 透明度 | |
23 | +@mixin opacity($opacity) { | |
24 | + -webkit-border-radius: $radius; | |
25 | + -moz-border-radius: $radius; | |
26 | + -ms-border-radius: $radius; | |
27 | + border-radius: $radius; | |
28 | +} | |
29 | + | |
30 | +//文字溢出省略显示 | |
31 | +@mixin text-ellipsis() { | |
32 | + white-space: nowrap; | |
33 | + overflow: hidden; | |
34 | + text-overflow: ellipsis; | |
35 | +} | |
36 | + | |
37 | +//盒模型阴影 | |
38 | +@mixin shadow($x, $y, $blur, $color) { | |
39 | + -webkit-box-shadow: $x $y $blur $color; | |
40 | + -moz-box-shadow: $x $y $blur $color; | |
41 | + box-shadow: $x $y $blur $color; | |
42 | +} | |
43 | + | |
44 | +/*单条border样式*/ | |
45 | +@mixin border-1px ($color, $direction) { | |
46 | + content: ''; | |
47 | + position: absolute; | |
48 | + background: $color; | |
49 | + @if $direction == left { | |
50 | + left: 0; | |
51 | + top: 0; | |
52 | + height: 100%; | |
53 | + width: 2px; | |
54 | + transform: scaleX(0.5); | |
55 | + transform-origin: left 0; | |
56 | + } | |
57 | + @if $direction == right { | |
58 | + right: 0; | |
59 | + top: 0; | |
60 | + height: 100%; | |
61 | + width: 2px; | |
62 | + transform: scaleX(0.5); | |
63 | + transform-origin: right 0; | |
64 | + } | |
65 | + @if $direction == bottom { | |
66 | + bottom: 0; | |
67 | + left: 0; | |
68 | + width: 100%; | |
69 | + height: 2px; | |
70 | + transform: scaleY(0.5); | |
71 | + transform-origin: 0 bottom; | |
72 | + } | |
73 | + @if $direction == top { | |
74 | + top: 0; | |
75 | + left: 0; | |
76 | + width: 100%; | |
77 | + height: 2px; | |
78 | + transform: scaleY(0.5); | |
79 | + transform-origin: 0 top; | |
80 | + } | |
81 | +} | |
82 | + | |
83 | +/*四条border样式*/ | |
84 | +@mixin all-border-1px ($color, $radius) { | |
85 | + content: ''; | |
86 | + position: absolute; | |
87 | + top: 0; | |
88 | + left: 0; | |
89 | + border: 2px solid $color; | |
90 | + border-radius: $radius * 2; | |
91 | + -webkit-box-sizing: border-box; | |
92 | + box-sizing: border-box; | |
93 | + width: 200%; | |
94 | + height: 200%; | |
95 | + -webkit-transform: scale(0.5); | |
96 | + transform: scale(0.5); | |
97 | + -webkit-transform-origin: left top; | |
98 | + transform-origin: left top; | |
99 | +} | |
100 | + | |
101 | + | |
102 | + | |
103 | + | |
104 | + | ... | ... |
src/assets/style/reset.css
0 → 100644
1 | +html { | |
2 | + font-family: "Helvetica Neue", Helvetica, STHeiTi, Arial, sans-serif; | |
3 | + -ms-text-size-adjust: 100%; | |
4 | + -webkit-text-size-adjust: 100%; | |
5 | + font-size: 62.5%; | |
6 | +} | |
7 | + | |
8 | +body { | |
9 | + margin: 0; | |
10 | + font-size: 1.4rem; | |
11 | + line-height: 1.5; | |
12 | + color: #333333; | |
13 | + background-color: white; | |
14 | + height: 100%; | |
15 | + overflow-x: hidden; | |
16 | + -webkit-overflow-scrolling: touch; | |
17 | +} | |
18 | + | |
19 | +article, | |
20 | +aside, | |
21 | +details, | |
22 | +figcaption, | |
23 | +figure, | |
24 | +footer, | |
25 | +header, | |
26 | +hgroup, | |
27 | +main, | |
28 | +nav, | |
29 | +section, | |
30 | +summary { | |
31 | + display: block; | |
32 | +} | |
33 | + | |
34 | +audio, | |
35 | +canvas, | |
36 | +progress, | |
37 | +video { | |
38 | + display: inline-block; | |
39 | + vertical-align: baseline; | |
40 | +} | |
41 | + | |
42 | +audio:not([controls]) { | |
43 | + display: none; | |
44 | + height: 0; | |
45 | +} | |
46 | + | |
47 | +[hidden], | |
48 | +template { | |
49 | + display: none; | |
50 | +} | |
51 | + | |
52 | +svg:not(:root) { | |
53 | + overflow: hidden; | |
54 | +} | |
55 | + | |
56 | +a { | |
57 | + background: transparent; | |
58 | + text-decoration: none; | |
59 | + -webkit-tap-highlight-color: transparent; | |
60 | + color: #0088cc; | |
61 | +} | |
62 | + | |
63 | +a:active { | |
64 | + outline: 0; | |
65 | +} | |
66 | + | |
67 | +a:active { | |
68 | + color: #006699; | |
69 | +} | |
70 | + | |
71 | +abbr[title] { | |
72 | + border-bottom: 1px dotted; | |
73 | +} | |
74 | + | |
75 | +b, | |
76 | +strong { | |
77 | + font-weight: bold; | |
78 | +} | |
79 | + | |
80 | +dfn { | |
81 | + font-style: italic; | |
82 | +} | |
83 | + | |
84 | +mark { | |
85 | + background: #ff0; | |
86 | + color: #000; | |
87 | +} | |
88 | + | |
89 | +small { | |
90 | + font-size: 80%; | |
91 | +} | |
92 | + | |
93 | +sub, | |
94 | +sup { | |
95 | + font-size: 75%; | |
96 | + line-height: 0; | |
97 | + position: relative; | |
98 | + vertical-align: baseline; | |
99 | +} | |
100 | + | |
101 | +sup { | |
102 | + top: -0.5em; | |
103 | +} | |
104 | + | |
105 | +sub { | |
106 | + bottom: -0.25em; | |
107 | +} | |
108 | + | |
109 | +img { | |
110 | + border: 0; | |
111 | + vertical-align: middle; | |
112 | +} | |
113 | + | |
114 | +hr { | |
115 | + -moz-box-sizing: content-box; | |
116 | + box-sizing: content-box; | |
117 | + height: 0; | |
118 | +} | |
119 | + | |
120 | +pre { | |
121 | + overflow: auto; | |
122 | + white-space: pre; | |
123 | + white-space: pre-wrap; | |
124 | + word-wrap: break-word; | |
125 | +} | |
126 | + | |
127 | +code, | |
128 | +kbd, | |
129 | +pre, | |
130 | +samp { | |
131 | + font-family: monospace, monospace; | |
132 | + font-size: 1em; | |
133 | +} | |
134 | + | |
135 | +button, | |
136 | +input, | |
137 | +optgroup, | |
138 | +select, | |
139 | +textarea { | |
140 | + color: inherit; | |
141 | + font: inherit; | |
142 | + margin: 0; | |
143 | +} | |
144 | + | |
145 | +button { | |
146 | + overflow: visible; | |
147 | +} | |
148 | + | |
149 | +button, | |
150 | +select { | |
151 | + text-transform: none; | |
152 | +} | |
153 | + | |
154 | +button, | |
155 | +html input[type="button"], | |
156 | +input[type="reset"], | |
157 | +input[type="submit"] { | |
158 | + -webkit-appearance: button; | |
159 | + cursor: pointer; | |
160 | +} | |
161 | + | |
162 | +button[disabled], | |
163 | +html input[disabled] { | |
164 | + cursor: default; | |
165 | +} | |
166 | + | |
167 | +button::-moz-focus-inner, | |
168 | +input::-moz-focus-inner { | |
169 | + border: 0; | |
170 | + padding: 0; | |
171 | +} | |
172 | + | |
173 | +input { | |
174 | + line-height: normal; | |
175 | +} | |
176 | + | |
177 | +input[type="checkbox"], | |
178 | +input[type="radio"] { | |
179 | + box-sizing: border-box; | |
180 | + padding: 0; | |
181 | +} | |
182 | + | |
183 | +input[type="number"]::-webkit-inner-spin-button, | |
184 | +input[type="number"]::-webkit-outer-spin-button { | |
185 | + height: auto; | |
186 | +} | |
187 | + | |
188 | +input[type="search"] { | |
189 | + -webkit-appearance: textfield; | |
190 | + -moz-box-sizing: border-box; | |
191 | + -webkit-box-sizing: border-box; | |
192 | + box-sizing: border-box; | |
193 | +} | |
194 | + | |
195 | +input[type="search"]::-webkit-search-cancel-button, | |
196 | +input[type="search"]::-webkit-search-decoration { | |
197 | + -webkit-appearance: none; | |
198 | +} | |
199 | + | |
200 | +fieldset { | |
201 | + border: 1px solid #c0c0c0; | |
202 | + margin: 0 2px; | |
203 | + padding: 0.35em 0.625em 0.75em; | |
204 | +} | |
205 | + | |
206 | +legend { | |
207 | + border: 0; | |
208 | + padding: 0; | |
209 | +} | |
210 | + | |
211 | +textarea { | |
212 | + overflow: auto; | |
213 | + resize: vertical; | |
214 | +} | |
215 | + | |
216 | +optgroup { | |
217 | + font-weight: bold; | |
218 | +} | |
219 | + | |
220 | +table { | |
221 | + border-collapse: collapse; | |
222 | + border-spacing: 0; | |
223 | +} | |
224 | + | |
225 | +td, | |
226 | +th { | |
227 | + padding: 0; | |
228 | +} | |
229 | + | |
230 | +html, | |
231 | +button, | |
232 | +input, | |
233 | +select, | |
234 | +textarea { | |
235 | + font-family: "Helvetica Neue", Helvetica, STHeiTi, Arial, sans-serif; | |
236 | +} | |
237 | + | |
238 | +h1, | |
239 | +h2, | |
240 | +h3, | |
241 | +h4, | |
242 | +h5, | |
243 | +h6, | |
244 | +p, | |
245 | +figure, | |
246 | +form, | |
247 | +blockquote { | |
248 | + margin: 0; | |
249 | +} | |
250 | + | |
251 | +ul, | |
252 | +ol, | |
253 | +li, | |
254 | +dl, | |
255 | +dd { | |
256 | + margin: 0; | |
257 | + padding: 0; | |
258 | +} | |
259 | + | |
260 | +ul, | |
261 | +ol { | |
262 | + list-style: none outside none; | |
263 | +} | |
264 | + | |
265 | +h1, | |
266 | +h2, | |
267 | +h3 { | |
268 | + line-height: 2; | |
269 | + font-weight: normal; | |
270 | +} | |
271 | + | |
272 | +h1 { | |
273 | + font-size: 1.8rem; | |
274 | +} | |
275 | + | |
276 | +h2 { | |
277 | + font-size: 1.6rem; | |
278 | +} | |
279 | + | |
280 | +h3 { | |
281 | + font-size: 1.4rem; | |
282 | +} | |
283 | + | |
284 | +input::-moz-placeholder, | |
285 | +textarea::-moz-placeholder { | |
286 | + color: #cccccc; | |
287 | +} | |
288 | + | |
289 | +input:-ms-input-placeholder, | |
290 | +textarea:-ms-input-placeholder { | |
291 | + color: #cccccc; | |
292 | +} | |
293 | + | |
294 | +input::-webkit-input-placeholder, | |
295 | +textarea::-webkit-input-placeholder { | |
296 | + color: #cccccc; | |
297 | +} | |
298 | + | |
299 | +* { | |
300 | + -webkit-box-sizing: border-box; | |
301 | + -moz-box-sizing: border-box; | |
302 | + box-sizing: border-box; | |
303 | +} | ... | ... |
src/components/HelloWorld.vue deleted
1 | -<template> | |
2 | - <div class="hello"> | |
3 | - <h1>{{ msg }}</h1> | |
4 | - <h2>Essential Links</h2> | |
5 | - <ul> | |
6 | - <li> | |
7 | - <a | |
8 | - href="https://vuejs.org" | |
9 | - target="_blank" | |
10 | - > | |
11 | - Core Docs | |
12 | - </a> | |
13 | - </li> | |
14 | - <li> | |
15 | - <a | |
16 | - href="https://forum.vuejs.org" | |
17 | - target="_blank" | |
18 | - > | |
19 | - Forum | |
20 | - </a> | |
21 | - </li> | |
22 | - <li> | |
23 | - <a | |
24 | - href="https://chat.vuejs.org" | |
25 | - target="_blank" | |
26 | - > | |
27 | - Community Chat | |
28 | - </a> | |
29 | - </li> | |
30 | - <li> | |
31 | - <a | |
32 | - href="https://twitter.com/vuejs" | |
33 | - target="_blank" | |
34 | - > | |
35 | ||
36 | - </a> | |
37 | - </li> | |
38 | - <br> | |
39 | - <li> | |
40 | - <a | |
41 | - href="http://vuejs-templates.github.io/webpack/" | |
42 | - target="_blank" | |
43 | - > | |
44 | - Docs for This Template | |
45 | - </a> | |
46 | - </li> | |
47 | - </ul> | |
48 | - <h2>Ecosystem</h2> | |
49 | - <ul> | |
50 | - <li> | |
51 | - <a | |
52 | - href="http://router.vuejs.org/" | |
53 | - target="_blank" | |
54 | - > | |
55 | - vue-router | |
56 | - </a> | |
57 | - </li> | |
58 | - <li> | |
59 | - <a | |
60 | - href="http://vuex.vuejs.org/" | |
61 | - target="_blank" | |
62 | - > | |
63 | - vuex | |
64 | - </a> | |
65 | - </li> | |
66 | - <li> | |
67 | - <a | |
68 | - href="http://vue-loader.vuejs.org/" | |
69 | - target="_blank" | |
70 | - > | |
71 | - vue-loader | |
72 | - </a> | |
73 | - </li> | |
74 | - <li> | |
75 | - <a | |
76 | - href="https://github.com/vuejs/awesome-vue" | |
77 | - target="_blank" | |
78 | - > | |
79 | - awesome-vue | |
80 | - </a> | |
81 | - </li> | |
82 | - </ul> | |
83 | - </div> | |
84 | -</template> | |
85 | - | |
86 | -<script> | |
87 | -export default { | |
88 | - name: 'HelloWorld', | |
89 | - data () { | |
90 | - return { | |
91 | - msg: 'Welcome to Your Vue.js App' | |
92 | - } | |
93 | - } | |
94 | -} | |
95 | -</script> | |
96 | - | |
97 | -<!-- Add "scoped" attribute to limit CSS to this component only --> | |
98 | -<style scoped> | |
99 | -h1, h2 { | |
100 | - font-weight: normal; | |
101 | -} | |
102 | -ul { | |
103 | - list-style-type: none; | |
104 | - padding: 0; | |
105 | -} | |
106 | -li { | |
107 | - display: inline-block; | |
108 | - margin: 0 10px; | |
109 | -} | |
110 | -a { | |
111 | - color: #42b983; | |
112 | -} | |
113 | -</style> |
src/components/geomagnetism.vue
0 → 100644
1 | +<template> | |
2 | + <div class="hello"> | |
3 | + 1 | |
4 | + </div> | |
5 | +</template> | |
6 | + | |
7 | +<script> | |
8 | +export default { | |
9 | + name: 'geomagnetism', | |
10 | + data () { | |
11 | + return { | |
12 | + msg: 'Welcome to Your Vue.js App' | |
13 | + } | |
14 | + } | |
15 | +} | |
16 | +</script> | |
17 | + | |
18 | +<!-- Add "scoped" attribute to limit CSS to this component only --> | |
19 | +<style scoped lang="scss"> | |
20 | +.hello{ | |
21 | + | |
22 | +} | |
23 | +</style> | ... | ... |
src/components/screen.vue
0 → 100644