1 | 'use strict'
|
2 |
|
3 | var through = require('through2')
|
4 | var processCss = require('./process-css')
|
5 | var options = require('./options')
|
6 |
|
7 | module.exports = function (fileName, opts) {
|
8 | opts = options.normalize(opts)
|
9 |
|
10 | if (options.skipIt(fileName, opts)) return through()
|
11 |
|
12 | var chunks = []
|
13 |
|
14 | return through(
|
15 | function (chunk, enc, next) {
|
16 | chunks.push(chunk)
|
17 | next()
|
18 | },
|
19 | function (done) {
|
20 | var buffer = Buffer.concat(chunks)
|
21 | var source = buffer.toString('utf-8')
|
22 |
|
23 | processCss(fileName, source, opts).then(function (moduleSource) {
|
24 | this.push(moduleSource)
|
25 | done()
|
26 | }.bind(this))
|
27 | .catch(done)
|
28 | }
|
29 | )
|
30 | }
|