rsnext/packages/next/build/webpack/loaders/next-minify-loader.ts
Tim Neutkens 6feca310d7
Revert ncc webpack (#7370)
* Revert "Add retrying to CircleCi and fixes for ncc'ed webpack (#7366)"

This reverts commit 5beb365d12.

* Revert "ncc Webpack build (#7301)"

This reverts commit bd8f3c625f.

# Conflicts:
#	packages/next/package.json
2019-05-17 13:25:46 +02:00

23 lines
602 B
TypeScript

import loaderUtils from 'loader-utils'
import { loader } from 'webpack'
import minify from '../plugins/terser-webpack-plugin/src/minify'
const nextMiniferLoader: loader.Loader = function(source) {
this.cacheable()
const options = loaderUtils.getOptions(this) || {}
const { error, code } = minify({
file: 'noop',
input: source as string,
terserOptions: { ...options.terserOptions, sourceMap: false },
})
if (error) {
this.callback(new Error(`Error from Terser: ${error.message}`))
return
}
this.callback(undefined, code)
return
}
export default nextMiniferLoader