Welcome to mirror list, hosted at ThFree Co, Russian Federation.

import.js « nodes « lib « postcss-less « node_modules « assets - github.com/fourtyone11/origin-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4b41bdf2f25a44cd34463d7931bee199246cfab6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* eslint no-param-reassign: off */

const tokenize = require('postcss/lib/tokenize');

const urlPattern = /^url\((.+)\)/;

module.exports = (node) => {
  const { name, params = '' } = node;

  if (name === 'import' && params.length) {
    node.import = true;

    const tokenizer = tokenize({ css: params });

    node.filename = params.replace(urlPattern, '$1');

    while (!tokenizer.endOfFile()) {
      const [type, content] = tokenizer.nextToken();

      if (type === 'word' && content === 'url') {
        return;
      } else if (type === 'brackets') {
        node.options = content;
        node.filename = params.replace(content, '').trim();
        break;
      }
    }
  }
};