Skip to content

Import

.luis files can include other .luis or CSS files via @import.


@import "./base.luis";
@import "./vendor.css";
@import url("./theme.css") screen;

.luis importCSS import
Compile behaviorResolved and inlined into the main sourcePreserved as an @import declaration
Visible in output?No — content is expandedYes — stays as @import
/* .luis import — content is expanded at compile time */
@import "./tokens.luis";
/* CSS import — carried to output as-is */
@import "./vendor.css";

@import does not need to be at the top of the file. It can appear after a selector block or at-rule.

--primary: #2060ff;
.btn { color: var(--primary); }
@import "./extra.luis";
.card { padding: 16px; }

Some at-rules have ordering requirements:

  • @charset must be the first declaration in the file — it comes before @layer, @import, and all other rules
  • @layer declarations must come before .luis imports and regular rules
/* ✓ Correct order */
@charset "UTF-8";
@layer base, components;
@import "./tokens.luis";
.btn { color: red; }
/* ✗ Wrong — @charset cannot come after rules */
@import "./tokens.luis";
@charset "UTF-8";
/* ✗ Wrong — @layer cannot come after rules */
@import "./tokens.luis";
@layer base, components;

When the order rule is violated, an invalid-directive-order or invalid-directive-position warning is produced.


If two .luis files import each other, an import-cycle warning is produced. A circular import does not stop compilation; the relevant import is skipped.

a.luis
@import "./b.luis";
/* b.luis */
@import "./a.luis"; /* → import-cycle warning */

LimitDefaultPurpose
maxImportDepth64Limits nested import depth
maxImportCount2,000Limits the total number of resolved imports
maxImportedBytes4,000,000Limits the total size of imported sources

Detailed example:

app.luis
@import "./a.luis";
@import "./b.luis";

If the a.luis -> ... -> z.luis chain exceeds the depth or total byte limit:

  1. In fail-soft mode the branch that exceeds the limit is cut at import resolution.
  2. A resource-limit warning is produced.
  3. Compilation continues with the other rules that are within the limit.

CodeWhen Produced
import-not-foundImport could not be resolved
import-cycleTwo or more .luis files import each other
invalid-import-urlUnsupported or unsafe URL used (javascript:, etc.)
unsupported-importImport format not supported by the compiler
duplicate-import-variableThe same variable was defined more than once from different imports
invalid-directive-orderDirectives like @charset, @layer are in the wrong order
invalid-directive-positionA directive is used in a disallowed position