C
C
chillbyheaven2020-02-19 14:01:42
JavaScript
chillbyheaven, 2020-02-19 14:01:42

Is it possible for a single js/json not to be bundled and minified, but just placed next to the bundle in the dist folder?

For example, in the build folder there will be a config folder 5e4d1573b7167463427856.jpeg
. And in this folder there will be my environments.json file without minification
5e4d15aea45fd625910995.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Michael, 2020-02-19
@chillbyheaven

https://github.com/webpack-contrib/copy-webpack-plugin

A
Anton Shvets, 2020-02-20
@Xuxicheta

add a file to assets
https://angular.io/guide/workspace-config#assets-c...
To prevent webpack from including it in the bundle, add a link to the script directly in index.html as <script src="..."></script>
In the application, do not import, but use from the global scope.
The second option is to use webpack's dynamic import.
Write

import('./mymodule').then(module => {
  // тут используем модуль
});

The file will be built separately, but will be minified. I don’t know how to configure it individually, I didn’t find the opportunity to configure TerserPlugin for a single import speaker.
You can specify the chunk name as
import(/* webpackChunkName: "myname" */'./mymodule')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question