Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda