A
A
Andrey Sokolov2017-05-16 11:51:13
JavaScript
Andrey Sokolov, 2017-05-16 11:51:13

webpack. How can I implement multiple versions of a site with the same codebase?

There is a project, it is necessary to implement several visually different versions of sites, but with a single code base.
I thought to write a loader for this, but I could not find how to get the entry name of the current assembly.
While in parallel I am looking for how this can be implemented through a plugin, at least self-written.
Here is an approximate structure of the component
component:
--component.ts (the default.html template is included in it)
--default.html
--second.html
At the output, we get 2 bundles
default.bundle.js and second.bundle.js, in which the only the necessary templates
Do not tell me how this can be implemented?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Sokolov, 2017-05-16
@Fokir

At the moment I found only 1 solution, make an array of webpack configurations, which is generated via map

module.exports = ["default", "second"].map(entryName => {
    return {
        ...
        {loader: "template-loader", options: {entry: entryName}}
        ...
    }
});

And in the template-loader lauder, just replace the templates with the ones you need, if they exist, otherwise use default

B
Boris Korobkov, 2017-05-16
@BorisKorobkov

It's easier to include another template on the backend.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question