mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-27 05:00:48 +08:00
32 lines
748 B
JavaScript
32 lines
748 B
JavaScript
const sass = require('node-sass')
|
|
const path = require('path')
|
|
|
|
function createStyleScheme (css) {
|
|
return css
|
|
.replace(':export', 'export default')
|
|
.replace(/:\s/g, `: '`)
|
|
.replace(/;/g, `',`)
|
|
}
|
|
|
|
module.exports = function naiveSCSSExportVariable () {
|
|
return {
|
|
name: 'naive-scss-export-variable',
|
|
resolveId (source, importer) {
|
|
if (source.endsWith('.scss')) {
|
|
return path.resolve(path.dirname(importer), source)
|
|
}
|
|
return null
|
|
},
|
|
load (id) {
|
|
if (id.endsWith('.scss')) {
|
|
const css = sass.renderSync({
|
|
file: id,
|
|
outputStyle: 'expanded'
|
|
}).css.toString()
|
|
const styleScheme = createStyleScheme(css)
|
|
return styleScheme
|
|
}
|
|
}
|
|
}
|
|
}
|