I have a issue about css compile order in Webpack 2 with vue-cli project.
In main.js, I imported a css library file named skeleton.css
. This include <a>
color style.
import Vue from 'vue'
import App from './App'
import router from './router'
import 'skeleton-css/css/skeleton.css'
In App.vue, I set <a>
color style as below
<style lang="scss">
a {
text-decoration: none;
color: #2c3e50;
}
</style>
When I compiled the code and open the chrome inspector. I found the wrong order insert style.
<style type="text/css">....</style> // App.vue inline style
<style type="text/css">....</style> // skeleton.css style
And my webpack 2 config with vue-cli
{
test: /\.scss$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "sass-loader"
}]
}
How should I do to adjust correct import style order?
You need reorder the
imports
in yourmain.js
, since it is the only thing that affects the order of<style>
tags in the resulting DOM:Now
skeleton.css
comes first, and everything else would come after it.