Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

windicss-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

windicss-webpack-plugin - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

26

dist/loaders/pitcher.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pitch = void 0;
const constants_1 = require("../constants");
const isTemplateLoader = (l) => /(\/|\\|@)transform-template/.test(l.path);
const postCSSLoader = (l) => /(\/|\\|@)postcss-loader/.test(l.path);
const cssLoader = (l) => /(\/|\\|@)css-loader/.test(l.path);
const isPitcherLoader = (l) => `${constants_1.NAME}:pitcher` === l.ident;
const pitch = function (remainingRequest) {
// remove the pitcher immediately
this.loaders.splice(0, 1);
const pitcherLoaderIndex = this.loaders.findIndex(isPitcherLoader);
if (pitcherLoaderIndex !== -1) {
this.loaders.splice(pitcherLoaderIndex, 1);
}
/*

@@ -16,16 +21,17 @@ * Move the position of the transform-template loader for Vue SFCs.

if (remainingRequest.indexOf('&type=style') > 0) {
// remove all instances of this loader
let templateLoaderIndex, templateLoader;
while ((templateLoaderIndex = this.loaders.findIndex(isTemplateLoader)) !== -1) {
templateLoader = this.loaders[templateLoaderIndex];
this.loaders.splice(templateLoaderIndex, 1);
}
let insertIndex = this.loaders.findIndex(postCSSLoader) + 1;
let insertIndex = this.loaders.findIndex(postCSSLoader);
// just in-case they don't have post-css for whatever reason we also search for the css-loader
if (insertIndex === -1) {
insertIndex = this.loaders.findIndex(cssLoader) + 1;
insertIndex = this.loaders.findIndex(cssLoader);
}
// insert in our loader at the right spot
if (insertIndex !== -1) {
this.loaders.splice(insertIndex, 0, templateLoader);
// remove all instances of the template-loader
let templateLoaderIndex, templateLoader;
while ((templateLoaderIndex = this.loaders.findIndex(isTemplateLoader)) !== -1) {
templateLoader = this.loaders[templateLoaderIndex];
this.loaders.splice(templateLoaderIndex, 1);
}
// re-insert the template-loader in the right spot
this.loaders.splice(insertIndex + 1, 0, templateLoader);
}

@@ -32,0 +38,0 @@ }

@@ -6,5 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("../constants");
const debug_1 = __importDefault(require("../debug"));
const upath_1 = require("upath");
function TransformCss(source) {

@@ -19,4 +17,2 @@ if (!this._compiler) {

}
// cache file changes to invalidate the virtual module
this.addDependency(upath_1.resolve(this.rootContext, constants_1.MODULE_ID_VIRTUAL));
// only transform css if there is an @apply

@@ -23,0 +19,0 @@ const hasWindiApply = source.indexOf('@apply') > -1;

@@ -6,5 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("../constants");
const debug_1 = __importDefault(require("../debug"));
const upath_1 = require("upath");
const _ = require('lodash');

@@ -27,4 +25,2 @@ const loaderUtils = require('loader-utils');

}
// cache file changes to invalidate the virtual module
this.addDependency(upath_1.resolve(this.rootContext, constants_1.MODULE_ID_VIRTUAL));
const hasHtmlWebpackPlugin = this.loaders.filter(loader => {

@@ -31,0 +27,0 @@ // loader name as unresolved module

@@ -19,7 +19,14 @@ "use strict";

try {
// avoid duplicate scanning on HMR
if (service.scanned && service.options.enableScan) {
service.options.enableScan = false;
}
const css = await service.generateCSS();
css.replace('(boot)', '(generated)');
callback(null, source + '\n' + css);
}
catch (e) {
callback(e, source + '\n' + `/* Error: ${JSON.stringify(e, null, 2)}*/`);
const error = JSON.stringify(e, null, 2);
this.emitError(`[Windi CSS] Failed to generate CSS. Error: ${error}`);
callback(e, source + '\n' + `/* Error: ${error}*/`);
}

@@ -57,6 +64,4 @@ };

for (const content of contents) {
// add file as a dependency to invalidate hmr caches
this.addDependency(content.id);
try {
service.extractFile(content.data, content.id, service.options.transformGroups);
await service.extractFile(content.data, content.id, service.options.transformGroups);
}

@@ -63,0 +68,0 @@ catch (e) {

@@ -20,7 +20,3 @@ "use strict";

// @todo validate options
this.options = {
transformCSS: true,
transformGroups: true,
...options,
};
this.options = Object.assign({ transformCSS: true, transformGroups: true }, options);
}

@@ -39,6 +35,3 @@ apply(compiler) {

// setup alias
compiler.options.resolve.alias = {
...compiler.options.resolve.alias,
[constants_1.MODULE_ID]: upath_1.resolve(compiler.context, virtualModulePath),
};
compiler.options.resolve.alias = Object.assign(Object.assign({}, compiler.options.resolve.alias), { [constants_1.MODULE_ID]: upath_1.resolve(compiler.context, virtualModulePath) });
debug_1.default.plugin('options', this.options);

@@ -45,0 +38,0 @@ /*

{
"name": "windicss-webpack-plugin",
"version": "0.6.0",
"version": "0.6.1",
"license": "MIT",

@@ -25,3 +25,2 @@ "author": {

"release": "dotenv release-it --",
"release:next": "dotenv release-it --preReleaseId=beta --npm.tag=next --github.preRelease",
"dev:svelte": "yarn build && cd example/svelte && yarn dev",

@@ -45,3 +44,3 @@ "dev:next": "yarn build && cd example/next && yarn dev",

"dependencies": {
"@windicss/plugin-utils": "next",
"@windicss/plugin-utils": "0.16.0",
"debug": "^4.3.1",

@@ -51,4 +50,4 @@ "loader-utils": "^2.0.0",

"upath": "^2.0.1",
"webpack-virtual-modules": "^0.4.2",
"windicss": "next"
"webpack-virtual-modules": "^0.4.3",
"windicss": "3.0.9"
},

@@ -55,0 +54,0 @@ "devDependencies": {

@@ -14,5 +14,2 @@ <h1 align='center'>windicss-webpack-plugin</h1>

<details>
<summary>Features</summary>
## Features

@@ -28,14 +25,7 @@

</details>
## Install
This branch is for [**Windi CSS v3.0**](https://windicss.org/posts/v30.html) support. Both `windicss` and `windicss-webpack-plugin` are release under `@next` tag at this moment.
Install them by:
```bash
npm i -D windicss-webpack-plugin@next windicss@next
# or
yarn add -D windicss-webpack-plugin@next windicss@next
yarn add windicss-webpack-plugin -D
# npm i windicss-webpack-plugin -D
```

@@ -67,2 +57,5 @@

### [Attributify Mode](https://windicss.org/posts/v30.html#attributify-mode)
```ts
// windi.config.ts
import { defineConfig } from 'windicss-webpack-plugin'

@@ -73,2 +66,39 @@ Enabled it by

// windi.config.ts
import { defineConfig } from 'windicss-webpack-plugin'
function range(size, startAt = 1) {
return Array.from(Array(size).keys()).map(i => i + startAt);
}
export default defineConfig({
safelist: [
range(30).map(i => `p-${i}`), // p-1 to p-3
range(10).map(i => `mt-${i}`) // mt-1 to mt-10
]
})
```
### Scanning
On server start, `windicss-webpack-plugin` will scan your source code and extract the utilities usages. By default,
only files under `src/` with extensions `vue, html, mdx, pug, jsx, tsx` will be included. If you want to enable scanning for other file type of locations, you can configure it via:
```ts
// windi.config.js
import { defineConfig } from 'windcss/helpers'
export default defineConfig({
extract: {
include: ['src/**/*.{vue,html,jsx,tsx}'],
exclude: ['node_modules', '.git']
}
})
```
Or in plugin options:
```ts
// webpack.config.js
import WebpackWindiCSSPlugin from 'windicss-webpack-plugin'
export default {

@@ -75,0 +105,0 @@ attributify: true

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc