This commit is contained in:
Valentin Silytuin 2024-05-29 00:25:49 +04:00
commit cf04b7d8c4
19 changed files with 1204 additions and 0 deletions

8
.editorconfig Normal file
View File

@ -0,0 +1,8 @@
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

4
.gitattributes vendored Normal file
View File

@ -0,0 +1,4 @@
.yarn/** linguist-vendored
.yarn/releases/* binary
.yarn/plugins/**/* binary
.pnp.* binary linguist-generated

98
.gitignore vendored Executable file
View File

@ -0,0 +1,98 @@
# Node.js
node_modules
# Yarn (https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored)
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
# ESLint
.eslintcache
# Stylelint
.stylelintcache
# Composer
vendor
# https://github.com/github/gitignore/blob/master/Global/Linux.gitignore
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk

11
.npmignore Normal file
View File

@ -0,0 +1,11 @@
.vccode
.yarn
.editorconfig
.gitattributes
.nvmrc
.pnp.cjs
.pnp.loader.mjs
.prettierignore
.yarnrc.yml
prettier.config.js
yarn.lock

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
20.12

2
.prettierignore Normal file
View File

@ -0,0 +1,2 @@
.vscode
.yarn

6
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"recommendations": [
"arcanis.vscode-zipfs",
"esbenp.prettier-vscode"
]
}

7
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"prettier.prettierPath": ".yarn/sdks/prettier/index.cjs"
}

894
.yarn/releases/yarn-4.2.2.cjs vendored Executable file

File diff suppressed because one or more lines are too long

5
.yarn/sdks/integrations.yml vendored Normal file
View File

@ -0,0 +1,5 @@
# This file is automatically generated by @yarnpkg/sdks.
# Manual changes might be lost!
integrations:
- vscode

20
.yarn/sdks/prettier/bin/prettier.cjs vendored Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = createRequire(absPnpApiPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier/bin/prettier.cjs
require(absPnpApiPath).setup();
}
}
// Defer to the real prettier/bin/prettier.cjs your application uses
module.exports = absRequire(`prettier/bin/prettier.cjs`);

20
.yarn/sdks/prettier/index.cjs vendored Normal file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);
const relPnpApiPath = "../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = createRequire(absPnpApiPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier
require(absPnpApiPath).setup();
}
}
// Defer to the real prettier your application uses
module.exports = absRequire(`prettier`);

7
.yarn/sdks/prettier/package.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
"name": "prettier",
"version": "3.2.5-sdk",
"main": "./index.cjs",
"type": "commonjs",
"bin": "./bin/prettier.cjs"
}

5
.yarnrc.yml Normal file
View File

@ -0,0 +1,5 @@
compressionLevel: mixed
enableGlobalCache: false
yarnPath: .yarn/releases/yarn-4.2.2.cjs

53
README.md Normal file
View File

@ -0,0 +1,53 @@
# lightningcss-loader
[Lightning CSS](https://lightningcss.dev) loader for [Webpack](https://webpack.js.org)
## Usage
```js
import { transform } from 'lightningcss';
return {
...,
rules: [
{
test: /\.css$/,
use: [
{
loader: '@advdominion/lightningcss-loader',
options: {
implementation: transform,
},
},
],
},
],
};
```
### Passing options to Lightning CSS
```js
import { transform } from 'lightningcss';
return {
...,
rules: [
{
test: /\.css$/,
use: [
{
loader: '@advdominion/lightningcss-loader',
options: {
implementation: transform,
drafts: {
customMedia: true,
},
minify: false,
},
},
],
},
],
};
```

20
index.js Normal file
View File

@ -0,0 +1,20 @@
export default function (source, sourceMap) {
const { implementation, ...options } = this.getOptions();
const callback = this.async();
if (typeof implementation !== 'function') {
throw new TypeError(
`[lightningcss-loader]: The "implementation" option is required and must provide "transform" function of the LightningCSS`,
);
}
const { code, map } = implementation({
filename: this.resourcePath,
code: Buffer.from(source),
sourceMap: this.sourceMap,
inputSourceMap: this.sourceMap && sourceMap ? JSON.stringify(sourceMap) : undefined,
...options,
});
callback(undefined, code.toString(), map && JSON.parse(map.toString()));
}

15
package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "@advdominion/lightningcss-loader",
"version": "1.0.0",
"type": "module",
"packageManager": "yarn@4.2.2",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://gitea.optiweb.ru/public/lightningcss-loader.git"
},
"license": "MIT",
"devDependencies": {
"prettier": "^3.2.5"
}
}

5
prettier.config.js Normal file
View File

@ -0,0 +1,5 @@
export default {
printWidth: 120,
tabWidth: 4,
singleQuote: true,
};

23
yarn.lock Normal file
View File

@ -0,0 +1,23 @@
# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!
__metadata:
version: 8
cacheKey: 10
"@advdominion/lightningcss-loader@workspace:.":
version: 0.0.0-use.local
resolution: "@advdominion/lightningcss-loader@workspace:."
dependencies:
prettier: "npm:^3.2.5"
languageName: unknown
linkType: soft
"prettier@npm:^3.2.5":
version: 3.2.5
resolution: "prettier@npm:3.2.5"
bin:
prettier: bin/prettier.cjs
checksum: 10/d509f9da0b70e8cacc561a1911c0d99ec75117faed27b95cc8534cb2349667dee6351b0ca83fa9d5703f14127faa52b798de40f5705f02d843da133fc3aa416a
languageName: node
linkType: hard