esbuild-plugin-less
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,1 +0,1 @@ | ||
var f=Object.create,o=Object.defineProperty,d=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,v=Object.getOwnPropertyNames,w=Object.getOwnPropertyDescriptor;var l=e=>o(e,"__esModule",{value:!0});var L=(e,s)=>{for(var t in s)o(e,t,{get:s[t],enumerable:!0})},D=(e,s,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of v(s))!u.call(e,a)&&a!=="default"&&o(e,a,{get:()=>s[a],enumerable:!(t=w(s,a))||t.enumerable});return e},p=e=>e&&e.__esModule?e:D(l(o(e!=null?f(d(e)):{},"default",{value:e,enumerable:!0})),e);l(exports);L(exports,{lessLoader:()=>P});var r=p(require("path")),i=p(require("fs")),c=p(require("less")),h="less";function P(e={}){return{name:"less-loader",setup:s=>{s.onResolve({filter:/\.less$/},t=>({path:r.resolve(process.cwd(),r.relative(process.cwd(),t.resolveDir),t.path),namespace:h})),s.onLoad({filter:/.*/,namespace:h},async t=>{let a=await i.promises.readFile(t.path,"utf-8"),n=r.dirname(t.path),m=r.basename(t.path);return{contents:(await c.default.render(a,{filename:m,rootpath:n,...e,paths:[...e.paths||[],n]})).css,loader:"css",resolveDir:n}})}}} | ||
var w=Object.create,m=Object.defineProperty,x=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty,L=Object.getOwnPropertyNames,C=Object.getOwnPropertyDescriptor;var h=t=>m(t,"__esModule",{value:!0});var R=(t,e)=>{for(var s in e)m(t,s,{get:e[s],enumerable:!0})},y=(t,e,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of L(e))!I.call(t,r)&&r!=="default"&&m(t,r,{get:()=>e[r],enumerable:!(s=C(e,r))||s.enumerable});return t},n=t=>y(h(m(t!=null?w(x(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);h(exports);R(exports,{lessLoader:()=>O});var c=n(require("path")),d=n(require("fs")),g=n(require("less"));var u=n(require("fs")),l=n(require("path")),F=/@import(?:\s+\((.*)\))?\s+['"](.*)['"]/,S=/@import(?:\s+\((.*)\))?\s+['"](.*)['"]/g,$=/(?:\/\*(?:[\s\S]*?)\*\/)|(\/\/(?:.*)$)/gm,D=[".css",".less"],p=t=>{try{let e=l.default.dirname(t),i=(u.default.readFileSync(t).toString("utf8").replace($,"").match(S)||[]).map(o=>o.match(F)[2]).filter(o=>!!o).map(o=>l.default.resolve(e,o));return i.reduce((o,f)=>[...o,...p(f)],i).filter(o=>D.includes(l.default.extname(o).toLowerCase()))}catch(e){return[]}};function O(t={}){return{name:"less-loader",setup:e=>{e.onResolve({filter:/\.less$/,namespace:"file"},s=>{let r=c.default.resolve(process.cwd(),c.default.relative(process.cwd(),s.resolveDir),s.path);return{path:r,watchFiles:e.initialOptions.watch?[r,...p(r)]:void 0}}),e.onLoad({filter:/\.less$/,namespace:"file"},async s=>{let r=await d.promises.readFile(s.path,"utf-8"),a=c.default.dirname(s.path),i=c.default.basename(s.path);return{contents:(await g.default.render(r,{filename:i,rootpath:a,...t,paths:[...t.paths||[],a]})).css,loader:"css",resolveDir:a}})}}}0&&(module.exports={lessLoader}); |
@@ -1,1 +0,6 @@ | ||
## [1.0.2](https://github.com/iam-medvedev/esbuild-plugin-less/compare/v1.0.1...v1.0.2) (2021-03-03) | ||
## [1.0.3](https://github.com/iam-medvedev/esbuild-plugin-less/compare/v1.0.2...v1.0.3) (2021-04-01) | ||
### Bug Fixes | ||
* 🐛 watch mode ([#10](https://github.com/iam-medvedev/esbuild-plugin-less/issues/10)) ([3480415](https://github.com/iam-medvedev/esbuild-plugin-less/commit/3480415f5aff20a0b4df9df02b3f1df69b945f6f)), closes [#9](https://github.com/iam-medvedev/esbuild-plugin-less/issues/9) |
{ | ||
"name": "esbuild-plugin-less", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "esbuild plugin for less files", | ||
@@ -19,3 +19,4 @@ "repository": "https://github.com/iam-medvedev/esbuild-plugin-less.git", | ||
"build": "NODE_ENV=production ts-node ./scripts/build.ts", | ||
"build:example": "ts-node ./example/build.ts", | ||
"dev:example": "ts-node ./example/build.ts", | ||
"build:example": "NODE_ENV=production ts-node ./example/build.ts", | ||
"commit": "yarn git-cz", | ||
@@ -44,3 +45,3 @@ "prepublish": "yarn test && yarn types && yarn build", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"esbuild": "^0.8.54", | ||
"esbuild": "^0.11.2", | ||
"git-cz": "^4.7.6", | ||
@@ -57,3 +58,3 @@ "husky": "^5.1.3", | ||
"peerDependencies": { | ||
"esbuild": "^0.8.x" | ||
"esbuild": "^0.11.x" | ||
}, | ||
@@ -60,0 +61,0 @@ "dependencies": { |
@@ -5,3 +5,4 @@ [![License: WTFPL](https://img.shields.io/badge/License-WTFPL-brightgreen.svg)](http://www.wtfpl.net/about/) | ||
[![npm version](https://badge.fury.io/js/esbuild-plugin-less.svg)](https://www.npmjs.com/package/esbuild-plugin-less) | ||
[![David](https://img.shields.io/david/dev/iam-medvedev/esbuild-plugin-less)](https://david-dm.org/iam-medvedev/esbuild-plugin-less) | ||
[![David](https://status.david-dm.org/gh/iam-medvedev/esbuild-plugin-less.svg?type=dev)](https://david-dm.org/iam-medvedev/esbuild-plugin-less) | ||
[![David](https://status.david-dm.org/gh/iam-medvedev/esbuild-plugin-less.svg?type=peer)](https://david-dm.org/iam-medvedev/esbuild-plugin-less) | ||
[![Codecov](https://img.shields.io/codecov/c/github/iam-medvedev/esbuild-plugin-less)](https://codecov.io/gh/iam-medvedev/esbuild-plugin-less) | ||
@@ -23,2 +24,4 @@ [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fiam-medvedev%2Fesbuild-plugin-less.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fiam-medvedev%2Fesbuild-plugin-less?ref=badge_shield) | ||
### Simple example | ||
You can see the example [here](./example). | ||
@@ -41,2 +44,22 @@ | ||
### Watch mode | ||
More information about watch mode [here](https://esbuild.github.io/api/#watch). | ||
```ts | ||
import { build } from 'esbuild'; | ||
import { lessLoader } from 'esbuild-plugin-less'; | ||
build({ | ||
watch: true, // enable watch mode | ||
entryPoints: [path.resolve(__dirname, 'index.ts')], | ||
bundle: true, | ||
outdir: path.resolve(__dirname, 'output'), | ||
plugins: [lessLoader()], | ||
loader: { | ||
'.ts': 'ts', | ||
}, | ||
}); | ||
``` | ||
## Options | ||
@@ -43,0 +66,0 @@ |
Sorry, the diff of this file is not supported yet
8902
8
18
71
5