Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
How to export sass list as array to js file

I have a file with sass variables, it has a list like this:

$columnsClasses: 'Id', 'Phase', 'Status', 'Source', 'Date'

and so I write the following at the same file to export this list

:export {
columnsClasses: $columnsClasses;
}

I need to import this list to JS file due to some reasons. But when I do that, I get just one big string instead of array.

like this: '"Id", "Phase", "Status", "Source", "Date"'

How should I export sass list to get an array in JS?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Currently ICSS treats any exported value as a literal string (and I don't know if it will ever be possible to extend the proposal with any interchangeable datatype syntax).

An exportedValue does not need to be quoted, it is already treated as a literal string.

So you have to convert it into an array inside your javascript. What you can do though is to utilize the ever useful, established, and standardized JSON syntax and just add brackets yourself:

// constants.module.scss
$columnsClasses: 'Id', 'Phase', 'Status', 'Source', 'Date';

:export {
    columnsClasses: [$columnsClasses];
}

in your js

import constants from './constants.module.scss'

const columnsClasses = JSON.parse(constants.columnsClasses);

columnsClasses.forEach(console.log);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!