Một mục tập trung giao diện trong kho dữ liệu GitHub của TopGit: sveltejs/svelte-preprocess, 1.8k sao, nhóm Frontend, TypeScript. A ✨ magical ✨ Svelte preprocessor with sensible defaults and support for: PostCSS, SCSS, Less, Stylus, Coffeescript, TypeScript, Pug and much more.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
A Svelte preprocessor with sensible defaults and support for: PostCSS, SCSS, Less, Stylus, CoffeeScript, TypeScript, Pug and much more.
What is it?
Getting Started
Usage
Migration Guide
Preprocessing
Preprocessors
Features
Template tag
External files
Global style
Modern JavaScript syntax
Replace values
Built-in support for commonly used languages
What is it?
Svelte's own parser understands only JavaScript, CSS and its HTML-like syntax. To make it possible to write components in other languages, such as TypeScript or SCSS, Svelte provides the preprocess API, which allows to easily transform the content of your markup and your style/script tags.
Writing your own preprocessor for, i.e SCSS is easy enough, but it can be cumbersome to have to always configure multiple preprocessors for the languages you'll be using.
svelte-preprocess is a custom svelte preprocessor that acts as a facilitator to use other languages with Svelte, providing multiple features, sensible defaults and a less noisy development experience.
It is recommended to use with svelte.config.js file, located at the project root. For other usage, please refer to usage documentation.
Historically, svelte-preprocess was the go-to option whenever you had a language other than JS/HTML/CSS used inside your Svelte files. Today, depending on your setup, you may no longer need it:
If you're using Svelte 5 and are only using type features of TypeScript (i.e. things that just "go away" after transpiling to JS), you don't need any preprocessor, Svelte handles this natively
If you're using Vite and are using TypeScript or common CSS preprocessors (PostCSS, SCSS, Less, ...), use the preprocessor that comes with vite-plugin-svelte instead
If these cases don't apply to you, use svelte-preprocess.
Features
Template tag
Vue-like support for defining your markup between a specific tag. The default tag is template but it can be customized.
Works best with nesting-enabled CSS preprocessors, but regular CSS selectors like div :global .global1 .global2 are also supported.
Note: needs PostCSS to be installed.
Modern JavaScript syntax
svelte-preprocess allows you to run your component code through Babel before sending it to the compiler, allowing you to use new language features such as optional operators and nullish coalescing. However, note that Babel should transpile your component code to the javascript version supported by the Svelte compiler, so ES6+.
For example, with @babel/preset-env your config could be:
import { sveltePreprocess } from 'svelte-preprocess'
...
preprocess: sveltePreprocess({
babel: {
presets: [
[
'@babel/preset-env',
{
loose: true,
// No need for babel to resolve modules
modules: false,
targets: {
// ! Very important. Target es6+
esmodules: true,
},
},
],
],
},
});
...
Note: If you want to transpile your app to be supported in older browsers, you must run babel from the context of your bundler.
Replace values
Replace a set of string patterns in your components markup by passing an array of [RegExp, ReplaceFn | string], the same arguments received by the String.prototype.replace method.
In example, to replace inject the value of process.env.NODE_ENV:
sveltejs/svelte-preprocess thuộc nhóm Frontend trên TopGit, cùng 4 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về sveltejs/svelte-preprocess ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/sveltejs/svelte-preprocess là nguồn chính thức.
sveltejs/svelte-preprocess có bao nhiêu sao?
sveltejs/svelte-preprocess có 1.8k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/sveltejs/svelte-preprocess. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
sveltejs/svelte-preprocess có những chủ đề gì?
GitHub topics của sveltejs/svelte-preprocess: "preprocess", "svelte", "sveltejs", "sveltekit". TopGit xếp repo vào nhóm Frontend.
sveltejs/svelte-preprocess còn đang phát triển không?
Commit gần nhất trên sveltejs/svelte-preprocess là 5 tháng trước (theo timestamp GitHub). Repo có 151 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
sveltejs/svelte-preprocess viết bằng ngôn ngữ gì?
sveltejs/svelte-preprocess chủ yếu viết bằng TypeScript. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Vì sao sveltejs/svelte-preprocess được xếp vào nhóm Frontend?
TopGit xếp sveltejs/svelte-preprocess vào nhóm Frontend dựa trên GitHub topics và mô tả của repo (gắn thẻ: "preprocess", "svelte", "sveltejs"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc svelte-preprocess có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về svelte-preprocess.