1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/server/build/loaders/emit-file-loader.js
Arunoda Susiripala 4563f68ad5 Revert "Emit ES6 code for module source in emit file load" (#2501)
* Revert "Update emotion example to use css instead of fragment (#2497)"

This reverts commit 5bd3a5f1d1.

* Revert "Fix "Deploy to now" link (#2489)"

This reverts commit df1cd7ebf3.

* Revert "Emit ES6 code for module source in emit file load (#2478)"

This reverts commit 3f50abcb51.
2017-07-08 11:07:17 +05:30

25 lines
729 B
JavaScript

import loaderUtils from 'loader-utils'
module.exports = function (content, sourceMap) {
this.cacheable()
const query = loaderUtils.getOptions(this)
const name = query.name || '[hash].[ext]'
const context = query.context || this.options.context
const regExp = query.regExp
const opts = { context, content, regExp }
const interpolatedName = loaderUtils.interpolateName(this, name, opts)
const emit = (code, map) => {
this.emitFile(interpolatedName, code, map)
this.callback(null, code, map)
}
if (query.transform) {
const transformed = query.transform({ content, sourceMap, interpolatedName })
return emit(transformed.content, transformed.sourceMap)
}
return emit(content, sourceMap)
}