Skip to content

Importing .less file using import results in error #11811

Closed as not planned
Closed as not planned
@MulesGaming

Description

Astro Info

> src@0.0.1 astro
> astro info

Astro                    v4.13.3
Node                     v22.3.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When importing a less css file in src and loading it with <link rel="stylesheet/less" type="text/css" href={baseStyles} /> you encounter a error when building. It works as expected in the dev server.

Error:

14:49:46 [ERROR] [vite] x Build failed in 340ms
src/layouts/Base-layout.astro (4:7): "default" is not exported by "src/styles/base.less", imported by "src/layouts/Base-layout.astro".
file: /home/mulesgaming/Documents/projects/new-website/src/layouts/Base-layout.astro:4:7

2: const currentURL = Astro.url
3: const { title, desc, icon } = Astro.props;
4: import baseStyles from '../styles/base.less'
          ^
5: ---

  Stack trace:
    at getRollupError (file:///home/mulesgaming/Documents/projects/new-website/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
    at Module.error (file:///home/mulesgaming/Documents/projects/new-website/node_modules/rollup/dist/es/shared/node-entry.js:13958:16)
    at ModuleScope.findVariable (file:///home/mulesgaming/Documents/projects/new-website/node_modules/rollup/dist/es/shared/node-entry.js:12110:39)
    at FunctionBodyScope.findVariable (file:///home/mulesgaming/Documents/projects/new-website/node_modules/rollup/dist/es/shared/node-entry.js:7465:38)
    at CallExpression.bind (file:///home/mulesgaming/Documents/projects/new-website/node_modules/rollup/dist/es/shared/node-entry.js:4804:28)

What's the expected result?

For it to build without a error.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-wuwehp?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions