Comments (7)
Start a new pull request in StackBlitz Codeflow.
from vite.
I'm not getting the same error with the repro:
[vite:css] @import must precede all other statements (besides @charset or empty @layer)
3 | @layer reset, base, variant, state, component;
4 |
5 | @import url(./tester.css) layer(base);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 |
7 | :root {
I get this warning, and the wording is slightly different from what you're showing. Is there some other configuration that causes it?
from vite.
@bluwy Not sure why the wording is different and its just a warning and not an error, but it seems like its the one.
from vite.
Here's the full error when I run Vite build
on my local
> tsc && vite build
vite v5.2.13 building for production...
✓ 11 modules transformed.
x Build failed in 730ms
error during build:
[vite:css] @import rules must precede all rules aside from @charset and @layer statements
file: /Users/ben/Projects/pretty3a/lib/ThemeProvider/ThemeProvider.module.css:4:8
SyntaxError: @import rules must precede all rules aside from @charset and @layer statements
ELIFECYCLE Command failed with exit code 1.
from vite.
@bluwy Did above help?
from vite.
Not much unfortunately. I don't know the code that could have trigger the error instead of a warning for me. It's hard to debug from there on.
from vite.
@bluwy The warning is also incorrect. I'm assuming it could be something on my config that is considering that same warning as an error but it looks like its from the same issue where the [vite:css]'s logic considers using @layer
above @import
to be incorrect, although it says it can be.
Here's my config for reference:
import { resolve } from 'path'
import { defineConfig } from 'vite'
import { libInjectCss } from 'vite-plugin-lib-inject-css'
import dts from 'vite-plugin-dts'
import react from '@vitejs/plugin-react'
const ReactCompilerConfig = {
sources: (filename: string) => {
return filename.indexOf('src/path/to/dir') !== -1;
},
};
export default defineConfig({
plugins: [
react({
babel: {
plugins: [
["babel-plugin-react-compiler", ReactCompilerConfig],
],
},
}),
libInjectCss(),
dts({
exclude: ['**/*.stories.tsx']
})
],
css: {
transformer: 'lightningcss',
},
build: {
sourcemap: true,
cssMinify: 'lightningcss',
lib: {
// Could also be a dictionary or array of multiple entry points
entry: {
index: resolve(__dirname, 'lib/main.ts'),
button: resolve(__dirname, 'lib/Button/index.ts'),
},
name: 'MyLib',
// the proper extensions will be added
fileName: 'my-lib',
},
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: ['react'],
output: {
// Put chunk files at <output>/chunks
chunkFileNames: 'chunks/[name].[hash].[format]',
// Put chunk styles at <output>/assets
assetFileNames: 'assets/[name][extname]',
entryFileNames: '[name].[format]',
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
react: 'React',
},
},
},
},
optimizeDeps: {
exclude: ['storybook']
}
})
from vite.
Related Issues (20)
- rollupOptions.input 指定多个文件入口时,生成的多个html中css加载顺序不一致 HOT 1
- When using JSX and there is a circular dependency, the component state will be reset
- `base` or `cwd` option for `import.meta.glob`
- Incorrect NODE_ENV value in /guide/env-and-mode HOT 2
- npm error code EUNSUPPORTEDPROTOCOL HOT 4
- Inconsistent outcomes when resolving directories with special characters HOT 1
- Fail to load packages installed from Git repo HOT 2
- Tree shaking dynamic import from VIte bundled React component library HOT 3
- Terminal not showing errors when running in dev mode. No error checking in code either HOT 2
- bug: vite 5.3.0 fails ionic build command HOT 6
- isInNodeModules check is too loose
- Unable to build the app HOT 4
- @vitejs/plugin-legacy breaks code: `Failed to resolve import "_" from "dist/main.js". Does the file exist?` HOT 2
- Vite+Qwik JavaScript template preset not working HOT 2
- Vite is seemingly creating empty/junk source maps when optimizing dependencies HOT 1
- Dynamic import syntax errors in 5.3 HOT 2
- Dynamic import not working with (group) routing HOT 1
- Support relative base path on dev server
- Improve error message for worker format errors
- CSS files are incorrectly excluded from `assets` array in `manifest.json`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vite.