P
P
Pavel2017-07-21 15:38:44
JavaScript
Pavel, 2017-07-21 15:38:44

Competent assembly in production using Webpack. How to cook?

Intro
There is a large Frankenstein monster portal, a lot of legacy code, poured developers. It is almost impossible to carry out a complete refactoring, and "it works - don't touch it", especially when the person who wrote the code has already quit.
Current State of Affairs
One part of the system is built entirely by webpack, written in Marionette/Backbone using ES6 modules. There are no problems with her. But the rest of the legacy code and styles would be nice to run through uglify/minify and postcss.
I would like to write new elements of the system in es6/7.
As a result, there are several webpack configs for each part of the system, each of which does:
1. Build certain js in a folder allocated for the subsystem;
2. Assembly of all styles (since our styles are global and there is one big bundle for everything);
Questions
1. How to implement version iteration system for styles and other js-bundls? You have to manually change the version in the url. What would be the best webpack plugin or approach to do this? (after all, you will have to write to an additional php file that runs all styles and scripts)
2. Since there are many parts of the system (more than 10), they are completely isolated from each other (not counting styles), there will be many configs and very similar ones, like Is this a better way to optimize? (best-practice)
3. What other set of tools/approaches/plugins should be used (not counting unit tests) with this approach?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem, 2017-07-24
@alfaslash

1. I didn’t quite understand the problem, in what form are versions for style files and bundles implemented / should be implemented? In most cases, it is enough to take a hash from a file and you can do it using php.
2. Depends on how similar the configs will be:
- You can import the config from one file and override the necessary parameters in other files;
- It is possible to take out the values ​​of some parameters (eg, plugins, resolve, rules) into separate constants and import them into various config files.
3. Styles can also be assembled with gulp, in my opinion it is more convenient and faster.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question