This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
sass
Archived
1
0
Fork 0
master
yutent 2023-02-21 16:38:26 +08:00
commit ab4486442c
4 changed files with 136 additions and 0 deletions

16
.gitignore vendored Normal file
View File

@ -0,0 +1,16 @@
.vscode
node_modules/
src/
dist/
*.sublime-project
*.sublime-workspace
package-lock.json
._*
.Spotlight-V100
.Trashes
.DS_Store
.AppleDouble
.LSOverride

33
package.json Normal file
View File

@ -0,0 +1,33 @@
{
"name": "@bytedo/sass",
"version": "1.58.3",
"description": "sass的精简版",
"author": "yutent <yutent.io@gmail.com>",
"main": "dist/index.js",
"files": [
"dist/*"
],
"scripts": {
"build": "node ./update.js"
},
"keywords": [
"sass",
"scss",
"node-sass",
"node-scss"
],
"repository": {
"type": "git",
"url": "https://github.com/bytedo/sass.git"
},
"dependencies": {
"immutable": "^4.0.0"
},
"devDependencies": {
"esbuild": "^0.17.8",
"iofs": "^1.5.3"
},
"engines": {
"node": ">=12.0.0"
}
}

17
readme.md Normal file
View File

@ -0,0 +1,17 @@
## sass
> [`sass`](https://www.npmjs.com/package/sass)的精简版。
### 说明
- 本包并未修改逻辑代码。
- 移除了`chokidar`和`source-map-js`2个包, 移除了作为命令行运行的配置。
### 出现背景
> 纯js环境运行, 出于代码体积要求, 尽量缩减不必要的依赖。
### 使用文档
请到 [`sass`](https://www.npmjs.com/package/sass) 查看。

70
update.mjs Normal file
View File

@ -0,0 +1,70 @@
/**
* {}
* @author yutent<yutent.io@gmail.com>
* @date 2023/02/15 22:46:25
*/
import Es from 'esbuild'
import fs from 'iofs'
import { resolve } from 'path'
import { exec } from 'child_process'
import pkg from './package.json' assert { type: 'json' }
const NPM_URL = 'https://registry.npmmirror.com'
const PKG_NAME = 'sass'
function download(url) {
return fetch(url).then(r => r.arrayBuffer())
}
export function execAsync(cmd) {
return new Promise((yes, no) => {
exec(cmd, { cwd: resolve('./') }, (err, res) => {
if (err) {
no(err)
} else {
yes(res)
}
})
})
}
!(async function () {
let { version, url } = await fetch(
'https://registry.npmmirror.com/' + PKG_NAME,
{
headers: {
'content-type': 'application/json',
accept: 'application/json'
}
}
)
.then(r => r.json())
.then(r => {
let v = r['dist-tags'].latest
let url = r.versions[v].dist.tarball
return { version: v, url }
})
let ab = await download(url)
pkg.version = version
fs.echo(JSON.stringify(pkg, null, 2), './package.json')
fs.echo(Buffer.from(ab), `./${PKG_NAME}.tgz`)
await execAsync(`tar -xzf ${PKG_NAME}.tgz`)
Es.buildSync({
entryPoints: ['package/sass.default.dart.js', 'package/sass.dart.js'],
outdir: 'dist',
platform: 'node',
minify: true,
bundle: false,
target: 'node12'
})
fs.mv('dist/sass.default.dart.js', 'src/index.js')
fs.rm('./package', true)
fs.rm(`./${PKG_NAME}.tgz`)
})()