-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.coffee
27 lines (20 loc) · 846 Bytes
/
index.coffee
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
ngmin = require 'ngmin'
OriginalSource = require 'webpack-core/lib/OriginalSource'
class NgMinPlugin
constructor: (@options) ->
@options = {} if typeof @options isnt 'object'
apply: (compiler) ->
compiler.plugin 'compilation', (compilation) ->
compilation.plugin 'optimize-chunk-assets', (chunks, callback) ->
files = []
chunks.forEach (chunk) ->
chunk.files.forEach (file) ->
files.push file
compilation.additionalChunkAssets.forEach (file) ->
files.push file
files.forEach (file) ->
map = compilation.assets[file].map() # preserve the map
value = ngmin.annotate compilation.assets[file].source(), @options
compilation.assets[file] = new OriginalSource value, file, map
callback()
module.exports = NgMinPlugin