Skip to content
This repository was archived by the owner on Dec 26, 2018. It is now read-only.

Fix errors with scoped modules #154

Merged
merged 1 commit into from
Dec 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/style-rewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var addId = postcss.plugin('add-id', function () {
*/

module.exports = function (id, css, scoped, options) {
var key = id + '!!' + css
var key = id + '!!' + scoped + '!!' + css
var val = cache.get(key)
if (val) {
return Promise.resolve(val)
Expand All @@ -56,9 +56,16 @@ module.exports = function (id, css, scoped, options) {
}

// scoped css rewrite
if (scoped) {
// make sure the addId plugin is only pushed once
if (scoped && plugins.indexOf(addId) === -1) {
plugins.push(addId)
}

// remove the addId plugin if the style block is not scoped
if (!scoped && plugins.indexOf(addId) !== -1) {
plugins.splice(plugins.indexOf(addId), 1)
}

// minification
if (process.env.NODE_ENV === 'production') {
plugins.push(require('cssnano')(assign({
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy