1.58.3
commit
ab4486442c
|
@ -0,0 +1,16 @@
|
|||
.vscode
|
||||
node_modules/
|
||||
src/
|
||||
dist/
|
||||
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
package-lock.json
|
||||
|
||||
._*
|
||||
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -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) 查看。
|
|
@ -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`)
|
||||
})()
|
Reference in New Issue