src/util.js
function queryImport(styles) {
    if (styles.indexOf('@import') < 0) return []
    const arr = []
    const ast = csstree.parse(styles);
    csstree.walk(ast, {
        enter: function (node) {
            if (node.type === 'Atrule' && node.name === 'import') {
                const pat = node.prelude.children.head.data.value
                arr.push(pat.substring(1, pat.length - 1))
            }
        }
    })
    return arr
}
function queryImport(styles) {
    if (styles.indexOf('@import') < 0) return []
    const arr = []
    const ast = csstree.parse(styles);
    csstree.walk(ast, {
        enter: function (node) {
            if (node.type === 'Atrule' && node.name === 'import') {
                const pat = node.prelude.children.head.data.value
                arr.push(pat.substring(1, pat.length - 1))
            }
        }
    })
    return arr
}
function queryImport ( styles ) { if ( styles . indexOf ( '@import' ) < 0 ) return [ ] const arr = [ ] const ast = csstree . parse ( styles ) ; csstree . walk ( ast , { enter : function ( node ) { if ( node . type === 'Atrule' && node . name === 'import' ) { const pat = node . prelude . children . head . data . value arr . push ( pat . substring ( 1 , pat . length - 1 ) ) } } } ) return arr }
get import content in css file,may import multi times
@param styles css file content
@returns {Array} result
get import content in css file may import multi times