namesny-com/babel.config.js

38 lines
763 B
JavaScript
Raw Normal View History

2019-02-20 20:27:34 +00:00
module.exports = function (api) {
const presets = [
'@babel/preset-env',
2020-01-09 22:51:27 +00:00
'@babel/preset-react'
2019-02-20 20:27:34 +00:00
]
const plugins = [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-template-literals',
'@babel/plugin-proposal-class-properties'
]
if (api.env() === 'development') {
plugins.push([
'css-modules-transform', {
2020-01-09 22:51:27 +00:00
generateScopedName: '[name]__[local]___[hash:base64:5]',
preprocessCss: processSass,
extensions: ['.css', '.scss']
2019-02-20 20:27:34 +00:00
}
])
}
return {
presets,
plugins
}
}
var sass = require('node-sass')
function processSass (data, filename) {
var result
result = sass.renderSync({
data: data,
file: filename
}).css
return result.toString('utf8')
}