This is a cute tool, but the real solution to this problem is to avoid Webpack altogether.
Parcel accomplishes everything Webpack does with literally ~0~ configuration. If you make the switch, it will be the most productive 20 minutes of your life. (Yes, I am bitter over the MANY hours of my life I've wasted fiddling with Webpack.)
I love parcel, I seem to personally have constant issues with my typescript react project related to breakpoints just completely not working, or when being triggered, mapping to completely other files.
I imagine it's a sourcemap issue I may post on the tracker, has anyone seen this themselves?
Wouldn't it make more sense to have a sort of "Spring Boot" [1] approach for Webpack, whereby a dependency like React (or a "webpack-react-starter") can list the features it needs to have enabled and Webpack can then automatically enable features based on that?
Tooling like this seems a bit backward, in the sense that you're now creating a tool to create configuration for a tool that runs other tools that~~stack overflow
>Instructs webpack to emit the required object as file and to return its public URL
From url-loader's README:
>The url-loader works like the file-loader, but can return a DataURL if the file is smaller than a byte limit.
They are interchangeable, do the same thing, but url-loader can generate a dataUrl if the file is small, like an png/svg icon, so you can save one request where the latency could be higher than the download time.
I think this feature should be built into file-loader and toggled via loader option.
Great stuff!. Specially at the beginning, webpack is intimidating and can turn complex quickly. Wish I had this when I began.
Another add-on I would recommend is the addition of the:
- target: 'node'
for those developer that are using webpack on the backend.
This is pretty nice. It's funny how all this time on Gulp/Grunt/Npm and a billion others, and finally we have something that seems to be staying still...
Now for the feature requests:
* Generally I have webpack.common.js for the common between all environments and webpack.config.js for dev (so the configuration file is named the default thing) and webpack.prod.js for production.
I was thinking about something similar. Making the webpack configuration accessible using a drag‘n‘drop editor, where you can define environments (prod, test, etc) and build configuration per environment using building blocks. JavaScript generation, JSON export (for imports), sharing, etc.
I was just thinking about the 'full circle' today.
OSes of the past: Windows, Variations of Unix's,
OSes of 2018: Android, IOS, All Varations of Browsers, plus all the old ones
---
Cross platform (cross-os) development of the past: nasty (Widget libraries (wxWindows, QT, ... ), os-abstraction libs )
Cross platform development of 2018: nasty still (react-native, xamarin, etc .. )
---
Development pipeline tools of the past: Automake/cmake, make, linker
Development pipeline tools of 2018: npm, webpack
---
Compiler front ends of the past (things that produce assembler or low-level C or stack-machine codes): various C++ front ends, Eifel, etc
Compiler front ends of 2018 (things that spit out javascript): babel (more like macro-assembler), Clojurescript, ReasonML, Fay, Nim .. ,etc
---
In current times, we also added Wireframe/Styling tools into our development pipeline (I do not think we had it in the past). Eg Bootstrap and other styling (that are not integrated into 'compile-time-verification' stage of the modern Front-end languages.
I realize that above is somewhat front-end-dev oriented, but I think the desire to share 'same language' for front and backend development, causes the blur.
I also would add that for data crunching and data distribution (eg CORBA, DRPC) of the past -- we have gained more options, higher quality and free. So I would say this is a material advance for our productivity.
It's a punctuation heavy format with a bunch of shell code mixed in, which means projects go from using one language (Python, Ruby, JavaScript etc) to three (whatever they were using previously plus Make plus shell).
Interesting. I was attempting to compile some bundles over the weekend and was noticing drastically larger chunk sizes. I realized this was because I had neglected to specify NODE_ENV=production, and my babel-loader was using my dev config (which leaves prop-types in the code). Based on your comment, and the above docs, I shouldn't be seeing what I'm seeing.
It's a convenience thing. Once you get used to it, it works well. You define a loader in your webpack config, which then decides what to do with the PNG.
Usually, what happens if you require a PNG is that it passes via url-loader or file-loader, and optionally image-loader. This'd mean that you'd get a string (either a full URL or a base64-encoded inline image if it's small enough) that points to the image, which is optionally minified by image-loader.
If you require CSS or SASS, your webpack loaders will ensure the CSS is loaded.
No, I get what is trying to be achieved, I am just questioning why it is being done this way and not something much simpler... I would much prefer that my JavaScript bundler only bundles JavaScript. Converting a PNG into a JavaScript module through base64 should be pretty trivial, so I'd prefer to do that with another tool. I do something similar for inlining CSS in my own projects.
You can use one tool to optimize and base64 inline images and another to compile SCSS and inline it of course. But then you discover that you also want to optimize and inline images placed within css url() properties so you implement that feature in your build pipeline, then you discover... you get the point. Webpack gives you a flexible configurable and extensible way to handle any such case in any environment which is why everyone uses it for modern frontend development. I think questioning webpack is like questioning why people are using dependency injection frameworks in modern java.
And then you wind up spending multiple days trying to figure out how to do something that doesn't quite fit in with what other people have already done.
How many times do we have to learn the same lessons over and over? Small tools that compose together is infinitely more flexible than any plugin based tool can possible be.
Importing PNGs to JS is about dependency-wrangling, not task-running.
That is, the point of using webpack isn't that it's the best way to optimize a bunch of PNGs. The point of webpack is that it can parse your dependency tree and figure out which PNGs are depended on by a given entry point. If you also want your PNGs optimized, you can do that with a webpack plugin or a separate tool, as you like - that's orthogonal to the matter of why it's useful to import PNGs into JS.
Yeah, sorry but I don't buy that. webpack outputs JavaScript bundles, not a dependency graph. Importing PNGs into JavaScript is only useful if you use a JavaScript AST to then do something with those imports.
I'm not selling it, and I don't follow what you're disagreeing with. Webpack can output JS bundles, but it understands dependencies between non-JS assets as well, and will process any file in the dependency graph any way you like.
As such the point of requiring a PNG into JS (or CSS, or a Vue/React component, etc) is to tell webpack there's a dependency on it. Then that image will get pulled in to the build process for entry points that need it, and not otherwise.
If I had to give one Tipp about front-end development: transition the buildsystem to gradle and call webpack from there. Also npm can be managed with it.
Then you can slowly introduce kotlin code, which is way more productive.
In the end I found that writing everything in kotlin, using tachyons for CSS, the kotlin-minifier for code minification and closure-compiler for optimization is the most stable way to go.
JavaScript isn't a productive language. Having build-tools in JS just complicates everything.
Parcel accomplishes everything Webpack does with literally ~0~ configuration. If you make the switch, it will be the most productive 20 minutes of your life. (Yes, I am bitter over the MANY hours of my life I've wasted fiddling with Webpack.)
https://parceljs.org/