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

extract-css-chunks-webpack-plugin

Package Overview
Dependencies
Maintainers
2
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extract-css-chunks-webpack-plugin - npm Package Compare versions

Comparing version 4.7.4 to 4.7.5

15

dist/index.js

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

/* eslint-disable class-methods-use-this */
const {

@@ -41,5 +42,4 @@ ConcatSource,

class CssDependencyTemplate {
apply() {} // eslint-disable-line class-methods-use-this
apply() {}
}

@@ -87,5 +87,4 @@

this.sourceMap = module.sourceMap;
} // eslint-disable-next-line class-methods-use-this
}
needRebuild() {

@@ -111,3 +110,2 @@ return true;

class CssModuleFactory {
// eslint-disable-next-line class-methods-use-this
create({

@@ -124,3 +122,3 @@ dependencies: [dependency]

(0, _schemaUtils.default)(_pluginOptions.default, options, 'Mini CSS Extract Plugin');
const insert = typeof options.insert === 'undefined' ? '"head"' : typeof options.insert === 'string' ? JSON.stringify(options.insert) : options.insert.toString();
const insert = options.insert ? options.insert.toString() : null;
this.options = Object.assign({

@@ -292,3 +290,3 @@ filename: DEFAULT_FILENAME,

} = this.options;
return Template.asString([source, '', `// ${pluginName} CSS loading`, `var cssChunks = ${JSON.stringify(chunkMap)};`, 'if(installedCssChunks[chunkId]) promises.push(installedCssChunks[chunkId]);', 'else if(installedCssChunks[chunkId] !== 0 && cssChunks[chunkId]) {', Template.indent(['promises.push(installedCssChunks[chunkId] = new Promise(function(resolve, reject) {', Template.indent([`var href = ${linkHrefPath};`, `var fullhref = ${mainTemplate.requireFn}.p + href;`, 'var existingLinkTags = document.getElementsByTagName("link");', 'for(var i = 0; i < existingLinkTags.length; i++) {', Template.indent(['var tag = existingLinkTags[i];', 'var dataHref = tag.getAttribute("data-href") || tag.getAttribute("href");', 'if(tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref)) return resolve();']), '}', 'var existingStyleTags = document.getElementsByTagName("style");', 'for(var i = 0; i < existingStyleTags.length; i++) {', Template.indent(['var tag = existingStyleTags[i];', 'var dataHref = tag.getAttribute("data-href");', 'if(dataHref === href || dataHref === fullhref) return resolve();']), '}', 'var linkTag = document.createElement("link");', 'linkTag.rel = "stylesheet";', 'linkTag.type = "text/css";', 'linkTag.onload = resolve;', 'linkTag.onerror = function(event) {', Template.indent(['var request = event && event.target && event.target.src || fullhref;', 'var err = new Error("Loading CSS chunk " + chunkId + " failed.\\n(" + request + ")");', 'err.code = "CSS_CHUNK_LOAD_FAILED";', 'err.request = request;', 'delete installedCssChunks[chunkId]', 'linkTag.parentNode.removeChild(linkTag)', 'reject(err);']), '};', 'linkTag.href = fullhref;', crossOriginLoading ? Template.asString([`if (linkTag.href.indexOf(window.location.origin + '/') !== 0) {`, Template.indent(`linkTag.crossOrigin = ${JSON.stringify(crossOriginLoading)};`), '}']) : '', `var insert = ${insert};`, `if (typeof insert === 'function') { insert(linkTag); }`, `else { var target = document.querySelector(${insert}); target && insert === 'body' ? target && target.insertBefore(linkTag,target.firstChild) : target.appendChild(linkTag); } `]), '}).then(function() {', Template.indent(['installedCssChunks[chunkId] = 0;']), '}));']), '}']);
return Template.asString([source, '', `// ${pluginName} CSS loading`, `var cssChunks = ${JSON.stringify(chunkMap)};`, 'if(installedCssChunks[chunkId]) promises.push(installedCssChunks[chunkId]);', 'else if(installedCssChunks[chunkId] !== 0 && cssChunks[chunkId]) {', Template.indent(['promises.push(installedCssChunks[chunkId] = new Promise(function(resolve, reject) {', Template.indent([`var href = ${linkHrefPath};`, `var fullhref = ${mainTemplate.requireFn}.p + href;`, 'var existingLinkTags = document.getElementsByTagName("link");', 'for(var i = 0; i < existingLinkTags.length; i++) {', Template.indent(['var tag = existingLinkTags[i];', 'var dataHref = tag.getAttribute("data-href") || tag.getAttribute("href");', 'if(tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref)) return resolve();']), '}', 'var existingStyleTags = document.getElementsByTagName("style");', 'for(var i = 0; i < existingStyleTags.length; i++) {', Template.indent(['var tag = existingStyleTags[i];', 'var dataHref = tag.getAttribute("data-href");', 'if(dataHref === href || dataHref === fullhref) return resolve();']), '}', 'var linkTag = document.createElement("link");', 'linkTag.rel = "stylesheet";', 'linkTag.type = "text/css";', 'linkTag.onload = resolve;', 'linkTag.onerror = function(event) {', Template.indent(['var request = event && event.target && event.target.src || fullhref;', 'var err = new Error("Loading CSS chunk " + chunkId + " failed.\\n(" + request + ")");', 'err.code = "CSS_CHUNK_LOAD_FAILED";', 'err.request = request;', 'delete installedCssChunks[chunkId]', 'linkTag.parentNode.removeChild(linkTag)', 'reject(err);']), '};', 'linkTag.href = fullhref;', crossOriginLoading ? Template.asString([`if (linkTag.href.indexOf(window.location.origin + '/') !== 0) {`, Template.indent(`linkTag.crossOrigin = ${JSON.stringify(crossOriginLoading)};`), '}']) : '', insert ? 'insert(linkTag);' : 'var head = document.getElementsByTagName("head")[0]; head.appendChild(linkTag)']), '}).then(function() {', Template.indent(['installedCssChunks[chunkId] = 0;']), '}));']), '}']);
}

@@ -299,5 +297,4 @@

});
} // eslint-disable-next-line class-methods-use-this
}
getCssChunkObject(mainChunk) {

@@ -304,0 +301,0 @@ const obj = {};

77

package.json
{
"name": "extract-css-chunks-webpack-plugin",
"version": "4.7.4",
"version": "4.7.5",
"description": "Extract CSS from chunks into stylesheets + HMR. Supports Webpack 4 + SSR",

@@ -38,2 +38,3 @@ "license": "MIT",

"scripts": {
"commit": "git-cz",
"start": "npm run build -- -w",

@@ -68,42 +69,48 @@ "prebuild": "npm run clean",

"dependencies": {
"loader-utils": "^1.1.0",
"loader-utils": "^2.0.0",
"normalize-url": "1.9.1",
"schema-utils": "^1.0.0",
"webpack-external-import": "^1.1.0-beta.3",
"webpack-external-import": "^2.2.4",
"webpack-sources": "^1.1.0"
},
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/preset-env": "^7.7.6",
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"@webpack-contrib/defaults": "^5.0.2",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-eslint": "^10.0.2",
"babel-jest": "^24.8.0",
"commitlint-azure-pipelines-cli": "^1.0.2",
"cross-env": "^5.2.0",
"css-loader": "^3.3.2",
"del": "^4.1.1",
"del-cli": "^1.1.0",
"es-check": "^5.0.0",
"eslint": "^6.7.2",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-prettier": "^3.1.2",
"file-loader": "^4.0.0",
"husky": "^3.0.0",
"jest": "^24.8.0",
"jest-junit": "^10.0.0",
"lint-staged": "^9.5.0",
"memfs": "^3.0.2",
"npm-run-all": "^4.1.5",
"prerender-loader": "^1.3.0",
"prettier": "^1.19.1",
"standard-version": "^7.0.1",
"webpack": "^4.41.4",
"webpack-cli": "^3.3.6",
"webpack-dev-server": "^3.7.2"
"@babel/cli": "7.8.4",
"@babel/core": "7.9.0",
"@babel/preset-env": "7.9.5",
"@commitlint/cli": "8.3.5",
"@commitlint/config-conventional": "8.3.4",
"@webpack-contrib/defaults": "6.3.0",
"@webpack-contrib/eslint-config-webpack": "3.0.0",
"babel-eslint": "10.1.0",
"babel-jest": "25.1.0",
"commitizen": "4.0.4",
"commitlint-azure-pipelines-cli": "1.0.3",
"cross-env": "7.0.2",
"css-loader": "3.5.2",
"cz-conventional-changelog": "3.1.0",
"del": "5.1.0",
"del-cli": "3.0.0",
"es-check": "5.1.0",
"eslint": "6.8.0",
"eslint-config-prettier": "6.10.1",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-prettier": "3.1.2",
"file-loader": "6.0.0",
"husky": "4.2.3",
"jest": "25.1.0",
"jest-dev-server": "4.4.0",
"jest-junit": "10.0.0",
"jest-puppeteer": "4.4.0",
"lint-staged": "10.0.8",
"memfs": "3.1.2",
"npm-run-all": "4.1.5",
"prerender-loader": "1.3.0",
"prettier": "1.19.1",
"puppeteer": "2.1.1",
"serve": "11.3.0",
"standard-version": "7.1.0",
"webpack": "4.42.0",
"webpack-cli": "3.3.11",
"webpack-dev-server": "3.10.3"
}
}

@@ -9,3 +9,3 @@ If you like our work, check out our Redux-based router <a href="https://github.com/faceyspacey/redux-first-router" target="_blank">redux-first-router</a> or its sucessor which, <a href="https://github.com/respond-framework/rudy" target="_blank">Rudy<a>

</a>
<img src="https://ssl.google-analytics.com/collect?v=1&t=event&ec=email&ea=open&t=event&tid=UA-120967034-1&z=1589684734&cid=9befe819-70e1-278b-50fc-859e6d1970cb&dt=ExtractCssChunks&dp=/email/ExtractCssChunks">
<a href="https://travis-ci.org/faceyspacey/extract-css-chunks-webpack-plugin">

@@ -33,3 +33,3 @@ <img src="https://travis-ci.org/faceyspacey/extract-css-chunks-webpack-plugin.svg?branch=master" alt="Build Status" />

So... why did we rebuild `extract-css-chunks`? What does it offer?
So... why did we rebuild `extract-css-chunks-webpack-plugin`? What does it offer?

@@ -70,3 +70,2 @@ It's got all the goodness of `mini-css-extract-plugin` but with 2 gleaming, sought after benefits.

test: /\.css$/i,
test: /\.css$/i,
use: [ExtractCssChunks.loader, 'css-loader'],

@@ -588,3 +587,3 @@ },

Type: `String|Function`
Type: `Function`
Default: `head`

@@ -598,14 +597,2 @@

#### `insert` as a string
Allows to configure a [CSS selector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector) that will be used to find the element where to append the styles (`link` elements).
```js
new ExtractCssChunksPlugin({
insert: '#my-container',
});
```
A new `<link>` element will be appended to the `#my-container` element.
#### `insert` as a function

@@ -612,0 +599,0 @@

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