build.styleResourcesLoader

https://github.com/yenshih/style-resources-loader
This commit is contained in:
Dmitri Efimenko 2017-11-21 02:56:14 +03:00
parent a315b71ea8
commit 9fb2fdf4f5
7 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,3 @@
# Using build.styleResources with Nuxt.js
https://nuxtjs.org/examples

View File

@ -0,0 +1 @@
$main: #ccc;

View File

@ -0,0 +1,9 @@
module.exports = {
build: {
styleResources: {
patterns: [
'./assets/resources.scss'
]
}
}
}

View File

@ -0,0 +1,11 @@
{
"name": "hello-nuxt",
"dependencies": {
"nuxt": "latest"
},
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start"
}
}

View File

@ -0,0 +1,12 @@
<style lang="scss">
.main {
background: $main;
}
</style>
<template>
<div class="main">
<h1>Welcome!</h1>
<nuxt-link to="/about">About page</nuxt-link>
</div>
</template>

View File

@ -56,10 +56,20 @@ export default function styleLoader(ext, loaders = [], isVueLoader = false) {
})
}
// https://github.com/yenshih/style-resources-loader
let styleResourcesLoader
if (this.options.build.styleResources) {
styleResourcesLoader = {
loader: 'style-resources-loader',
options: this.options.build.styleResources
}
}
return [
vueStyleLoader,
cssLoader,
postcssLoader,
...loaders
...loaders,
styleResourcesLoader
].filter(l => l)
}

View File

@ -108,6 +108,7 @@
"server-destroy": "^1.0.1",
"source-map": "^0.6.1",
"source-map-support": "^0.5.0",
"style-resources-loader": "^0.3.0",
"uglifyjs-webpack-plugin": "^1.0.1",
"url-loader": "^0.6.2",
"vue": "^2.5.6",