How to use the postcss.comment function in postcss

To help you get started, we’ve selected a few postcss examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 2createStudio / postcss-sprites / index.js View on Github external
color = getColor(decl);

						// Extract color to background-color propery
						if (color && color.length === 1) {
							declaration = postcss.decl({
								prop: 'background-color',
								value: color[0]
							});
							declaration.raws.before = ' ';

							rule.append(declaration);
						}
					}

					if (decl.prop === BACKGROUND || decl.prop === BACKGROUND_IMAGE) {
						image.token = postcss.comment({
							text: image.url,
						});

						image.token.raws.before = ' ';
						image.token.raws.left   = '@replace|';
						image.token.raws.right  = '';

						// Replace the declaration with a comment token
						// which will be used later for reference.
						decl.replaceWith(image.token);
					}
				}
			}
		});
github AleshaOleg / postcss-sass / parser.es6 View on Github external
comment (node, parent, inline) {
    // https://github.com/nodesecurity/eslint-plugin-security#detect-unsafe-regex
    // eslint-disable-next-line security/detect-unsafe-regex
    let text = node.content.match(/^(\s*)((?:\S[\S\s]*?)?)(\s*)$/)

    this.raws.comment = true

    let comment = Object.assign(postcss.comment(), {
      text: text[2],
      raws: {
        before: this.raws.before || DEFAULT_COMMENT_DECL.before,
        left: text[1],
        right: text[3],
        inline
      },
      source: {
        start: {
          line: node.start.line,
          column: node.start.column
        },
        end: node.end,
        input: this.input
      },
      parent
github gucong3000 / postcss-syntax / packages / postcss-jsx / object-parser.js View on Github external
comment (node, parent) {
		if (!parent.nodes || (node.start < parent.raws.node.start && parent.type !== "root" && parent.parent)) {
			return this.comment(node, parent.parent);
		}
		const text = node.value.match(/^(\s*)((?:\S[\s\S]*?)?)(\s*)$/);
		const comment = postcss.comment({
			text: text[2],
			raws: {
				node,
				left: text[1],
				right: text[3],
				inline: node.type === "CommentLine",
			},
		});

		parent.push(comment);
		return comment;
	}
}
github gucong3000 / postcss-jsx / object-parser.js View on Github external
comment (node, parent) {
		if (!parent.nodes || (node.start < parent.raws.node.start && parent.type !== "root" && parent.parent)) {
			return this.comment(node, parent.parent);
		}
		const text = node.value.match(/^(\s*)((?:\S[\s\S]*?)?)(\s*)$/);
		const comment = postcss.comment({
			text: text[2],
			raws: {
				node,
				left: text[1],
				right: text[3],
				inline: node.type === "CommentLine",
			},
		});

		parent.push(comment);
		return comment;
	}
}
github uikit / uikit / build / less.js View on Github external
css => {
                    css.insertBefore(css.nodes[0], postcss.comment({text: 'rtl:begin:rename'}));
                    css.insertAfter(css.nodes[css.nodes.length - 1], postcss.comment({text: 'rtl:end:rename'}));
                },
                rtlcss({
github glebmachine / postcss-easysprites / lib / tokens.js View on Github external
function setCommentToken(image) {
  const imageObj = image;
  imageObj.token = postcss.comment({
    text: imageObj.url,
    raws: {
      before: ' ',
      left: '@replace|',
      right: '',
    },
  });
}
github WolfgangKluge / postcss-media-variables / index.js View on Github external
function createHelperRule() {
    var rule = postcss.rule({
        selector: helperSelector
    });

    rule.append(
        postcss.comment({
            text: 'If you can see this comment, you might have forgotten to add\n' +
                  'postcss-media-variables to the plugin list for a second time.\n\n' +
                  'Otherwise, it\'s a bug :) Sorry\n' +
                  'Please report here: https://github.com/WolfgangKluge/postcss-media-variables/issues'
        })
    );

    return rule;
}