automatically inject style files based on the style path
pnpm add vue-cli-plugin-inject-style -D
yarn add vue-cli-plugin-inject-style -D
npm install vue-cli-plugin-inject-style -D
vue add vue-cli-plugin-inject-style
export interface InjectStyle {
/**
* @description style root
* @default src/style
*/
path: string;
/**
* @description style suffix
* @default ["scss","less"]
*/
suffixs: suffix[];
}
// vue.config.js
const path = require('node:path');
const { defineConfig } = require('@vue/cli-service');
module.exports = defineConfig({
transpileDependencies: true,
css: {
sourceMap: false,
loaderOptions: {
// manual add
scss: {
additionalData: '@import "~@/styles/index.scss";'
}
}
},
pluginOptions: {
'vue-cli-plugin-inject-style': {
path: path.join(__dirname, 'src', 'style'),
suffixs: ['scss', 'less']
}
}
});