-
Notifications
You must be signed in to change notification settings - Fork 0
Custom Build
This project is using webpack to create a build.
So it's kinda simple to create a custom build.
Just follow the steps below.
(If you want you can clone the repository on Gitpod which will do these steps for you automatically)
To create a custom build, you need to have the repository in your machine.
One way to do that it’s cloning the repository, opening a new terminal, and pasting this code:
(You need to have git installed on your machine)
git clone https://gitlab.com/201flaviosilva/utilsjs.git
After clone the repository, you need to move to the project folder to start working :)
cd utilsjs
Then install the dependencies
npm install
In the file tree you'll find a webpack.config.js
file, open and you will find a configuration more or less similar to the one below.
const path = require("path");
module.exports = {
mode: "production",
entry: "./src/index.js",
optimization: { minimize: true, }, // false/true
experiments: { outputModule: true, },
output: {
path: path.resolve("build"),
filename: "utils.min.js", // "utils.js"/"utils.min.js"
libraryTarget: "window", // module/commonjs2/window // https://webpack.js.org/configuration/output/#outputlibrarytarget
},
module: {
rules: [
{
test: /\.js?$/,
exclude: /(node_modules)/,
use: "babel-loader",
},
],
},
resolve: { extensions: [".js"], },
};
You probably just will want to change 3 properties:
In the property optimization
you'll find a property called minimize
that will be used to decide if the build will be development mode or not (minimize or not).
- If you want to development build, just set it to
false
. - If you want to production build, just set it to
true
.
In the property filename
you'll find the name of the file that will be created (the output file). Just change the file name to whatever name you need.
Example:
-
utils.min.js
; -
build.js
; - etc...
In the property libraryTarget
you'll find the target of the library.
- If you want to create a module build, just set it to
module
. - If you want to create a node build, just set it to
commonjs2
. - If you want to create a window build, just set it to
window
. - Etc... you can find more information in the webpack documentation.
Finally, you'll need to run the command npm run compile
in the terminal.
Check your folder tree, and in the folder build you'll find the file build file with the name of the file you've changed in the configuration.