diff --git a/examples/style-resources/README.md b/examples/style-resources/README.md new file mode 100644 index 0000000000..58371a7551 --- /dev/null +++ b/examples/style-resources/README.md @@ -0,0 +1,3 @@ +# Using build.styleResources with Nuxt.js + +https://nuxtjs.org/examples diff --git a/examples/style-resources/assets/resources.scss b/examples/style-resources/assets/resources.scss new file mode 100644 index 0000000000..81a376da5c --- /dev/null +++ b/examples/style-resources/assets/resources.scss @@ -0,0 +1 @@ +$main: #ccc; diff --git a/examples/style-resources/nuxt.config.js b/examples/style-resources/nuxt.config.js new file mode 100644 index 0000000000..ed8339dee0 --- /dev/null +++ b/examples/style-resources/nuxt.config.js @@ -0,0 +1,9 @@ +module.exports = { + build: { + styleResources: { + patterns: [ + './assets/resources.scss' + ] + } + } +} diff --git a/examples/style-resources/package.json b/examples/style-resources/package.json new file mode 100644 index 0000000000..6e9386ab8b --- /dev/null +++ b/examples/style-resources/package.json @@ -0,0 +1,15 @@ +{ + "name": "style-resources", + "dependencies": { + "nuxt": "latest" + }, + "scripts": { + "dev": "nuxt", + "build": "nuxt build", + "start": "nuxt start" + }, + "devDependencies": { + "node-sass": "^4.7.2", + "sass-loader": "^6.0.6" + } +} diff --git a/examples/style-resources/pages/index.vue b/examples/style-resources/pages/index.vue new file mode 100755 index 0000000000..d414f78af6 --- /dev/null +++ b/examples/style-resources/pages/index.vue @@ -0,0 +1,12 @@ + + + diff --git a/lib/builder/webpack/style-loader.js b/lib/builder/webpack/style-loader.js index 1e4b71171d..90f29d57be 100755 --- a/lib/builder/webpack/style-loader.js +++ b/lib/builder/webpack/style-loader.js @@ -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) } diff --git a/package.json b/package.json index 587da9634f..f82912b4eb 100644 --- a/package.json +++ b/package.json @@ -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",