webpack-merge-and-include-globally icon indicating copy to clipboard operation
webpack-merge-and-include-globally copied to clipboard

Symfony Encore – minify using Terser

Open jremen opened this issue 5 years ago • 1 comments

Hello, I'm trying to use this plugin with webpack encore. I can concate JS files with encore webpack config like this:

const MergeIntoSingleFilePlugin = require('webpack-merge-and-include-globally'); .addPlugin( new MergeIntoSingleFilePlugin({ files: {} })

But I'm not able to use transform function with Terser plugin like: tranform: { 'myfile.js': code => new TerserPlugin({include: 'myfile.js.js'}).minify(code).code }

It seems like terser will not notify that my file exists at all or is running before concatenation is finished. File is concatenated just fine, but minification doesn't work.

Also, I'm aware that Terser is already part of Encore and I don't want to call it like that, but this is probably questions for encore developers.

jremen avatar Mar 19 '20 08:03 jremen

nevermind, solved: transform: { 'myfile.js': function(fileContent, path) { return uglifyJsContents.minify(fileContent.toString()).code.toString() } }

jremen avatar Mar 19 '20 12:03 jremen