-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
33 lines (25 loc) · 1.02 KB
/
index.js
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
30
31
32
33
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author - Stefan Friedl @DoubleU23
*/
var loaderUtils = require('loader-utils')
, path = require('path')
, nativeCss = require('@stackr23/styleobjects').default
, fs = require('fs')
var transformToNestedDomStyleObjects = require('./lib/transformToNestedDomStyleObjects.js').default
module.exports = function(content) {
if (process.env.NODE_ENV === 'production')
this.cacheable && this.cacheable()
var options = Object.assign(
{},
{transform: true}, // defaultOptions
loaderUtils.getOptions(this) // could be null
)
// TBD: interpolateName()
// https://github.com/webpack/loader-utils#interpolatename
var result = nativeCss.convert(content)
// TBD: use "humps" for transformationHe
, returnVal = options.transform ? transformToNestedDomStyleObjects(result) : result
return 'module.exports = ' + JSON.stringify(result)
}
module.exports.raw = true