Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
Vite: Building a SASS file as it is written

I am building a library using Vite/Vue3/Quasar and I would like to export a quasar-variables.sass file as it is written without it being compiled or anything. Just straight SASS file that I can import to my other projects.

Is this possible with Vite?

Here is my vite.config.js:


import { resolve } from 'path';
import { defineConfig } from 'vite';
import { quasar, transformAssetUrls } from '@quasar/vite-plugin';
import eslintPlugin from 'vite-plugin-eslint';
import vue from '@vitejs/plugin-vue';

// https://vitejs.dev/config/
export default defineConfig({
    build: {
        lib: {
            entry: resolve(__dirname, 'src/index.js'),
            name: 'AvvinueClowder',
            fileName: (format) => `avvinue-clowder.${format}.js`,
        },
        rollupOptions: {
            external: ['vue'],
            output: {
                globals: {
                    vue: 'Vue',
                },
            },
        },
    },
    plugins: [
        vue({
            template: { transformAssetUrls },
        }),
        eslintPlugin(),
        quasar({
            sassVariables: 'src/style/_quasar-variables.sass',
        }),
    ],
    resolve: {
        alias: {
            '@': resolve(__dirname, './src'),
        },
    },
});

And part of my package.json:

    "version": "2.0.9",
    "files": [
        "dist"
    ],
    "main": "./dist/avvinue-clowder.umd.js",
    "module": "./dist/avvinue-clowder.es.js",
    "exports": {
        ".": {
            "import": "./dist/avvinue-clowder.es.js",
            "require": "./dist/avvinue-clowder.umd.js"
        }
    },
    "scripts": {
        "dev": "vite",
        "build": "vite build",
        "preview": "vite preview"
    },

And this is what gets spit out in the dist folder: enter image description here

Right now everything gets converted to simple CSS and the variables seem to get lost, which is forcing me to declare multiple variable files in multiple repositories, instead of just importing it from my NPM library I'm creating.

Thank you!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can use the rollup copy plugin to copy your file into dist folder

import copy from 'rollup-plugin-copy'
plugins: [
    copy({
      targets: [
        { src: 'src/style/_quasar-variables.sass', dest: 'dist/style' }
      ]
    })
  ]

Another way, you can just add your file to npm by excluding it from .npmignore file

/src  <- This line prevents uploading the whole src folder to npm
!src/style/_quasar-variables.sass  <- This will add your file to npm package
about 4 years ago · Juan Pablo Isaza Report

0

For Vite specifically, its easier if you just create a /public folder in your root and add files/assets that shouldn't be altered by the build script.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!