This package is a Vue CLI plugin designed to simplify the integration of `style-resources-loader` into Vue projects managed by Vue CLI. Its primary function is to automatically inject global style resources, such as Sass variables, Less mixins, or Stylus functions, into all relevant preprocessor files across your project, eliminating the need for repetitive `@import` statements in every component or style block. The current stable version is `v0.1.5`. Release cadence has been irregular, primarily for dependency upgrades. While effective for existing Vue CLI projects, its relevance for new Vue 3 projects is diminishing as the ecosystem shifts towards build tools like Vite, which use different plugin architectures. It acts as a configuration abstraction over `style-resources-loader` itself.
npm install vue-cli-plugin-style-resources-loaderVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install the plugin using `vue add` and configure global style resource injection in `vue.config.js`. It shows how to automatically make Sass variables and mixins available in all `.scss` files without explicit `@import` statements.
Install the required preprocessor loader: `npm install -D sass-loader node-sass` (for scss/sass), `less-loader less`, or `stylus-loader stylus`.
Use `path.resolve(__dirname, './src/styles/**/*.scss')` for robust path resolution. Verify patterns with a glob testing tool if unsure.
For new Vite projects, consider using a Vite plugin like `vite-plugin-style-resources` or manually configuring `vite.config.js` to achieve similar global style injection using Vite's native preprocessor options.
If encountering issues, try pinning `style-resources-loader` to a compatible version, or investigate the underlying `style-resources-loader` repository for known compatibility issues.
Install the necessary loader: `npm install -D sass-loader node-sass` (for Sass/SCSS), `npm install -D less-loader less` (for Less), or `npm install -D stylus-loader stylus` (for Stylus).
Ensure `path = require('path')` is at the top of `vue.config.js` and all entries in the `patterns` array are valid strings, ideally absolute paths using `path.resolve`.Ensure that `pluginOptions` is used for the `style-resources-loader` configuration and avoid conflicting `chainWebpack` rules that target the same preprocessor loaders that the plugin is attempting to configure. Consult the `vue-cli` documentation for proper `chainWebpack` usage.