1

I want to minify my files using uglifyjs-webpack.

For example I have a source file core/js/test and want to minify it and send it to min/js/test.

Just using a source and respective output, how do I use it with webpack.

Sri
  • 63
  • 2
  • 10
  • 1
    How is `means.org` relevant to your question? How does your current webpack configuration file look like? What is the problem with your current webpack setup? – t.niese Jul 12 '18 at 08:40
  • currently, I don't have any web pack setup in my application. In mean the way of assigning the client files is different, So Just in case I am mentioning it might be of any help to understand my working environment – Sri Jul 12 '18 at 08:52
  • When you ask a question on SO you should show a minimal research effort. In your case this means that you should include your webpack configuration file, which shows your attempt to include the webpack uglifyjs plugin. And an explanation what does not work. – t.niese Jul 12 '18 at 09:05
  • Okay I will try researching on this, thanks fo your kind suggestion – Sri Jul 12 '18 at 09:30

2 Answers2

1

I often just use the optimization: {minimize: true} option (see this) since webpack 4.

const path = require("path"); 

module.exports = {
  context: __dirname,
  entry: "/origin/main.js",
  output: {
      path: path.resolve("./min/js/"),
      filename: "test.js"
  },
  optimization: {
    minimize: false
  }
};

However, webpack still allows you to override the default implementation using the UglifyjsWebpackPlugin. I'd advise you to have a look at the docs in here, they seem to explain it quite alright.

fpintodacosta
  • 98
  • 1
  • 8
  • This solution seems promising but, could you explain how to use this in my file, since I'm a newbie in using web pack. – Sri Jul 12 '18 at 09:05
  • 1
    As far as I can think of, I'd need quite a lot to try and explain you in more detail. This is basically the bulk of a very simplistic `webpack.config.js` file, which'd set up its processing. As @t.niese says above, I really think you should first go through an effort of reasearching and maybe sparing some time for tutorialing too. [Some config help](https://webpack.js.org/configuration/) and [simple getting started](https://webpack.js.org/guides/getting-started/) – fpintodacosta Jul 12 '18 at 09:14
  • 1
    Okay, I will check the resources on web pack and then I will use your solution. I will get back with the response thank you. – Sri Jul 12 '18 at 09:31
  • Thanks, I have done a bit research on this and tried your solution, It worked like magic. – Sri Jul 12 '18 at 11:18
-1

You might like this web site. It will help you to minify. minifier

olgunyldz
  • 531
  • 3
  • 8