Under the hood
Build process
Custom build process
You can use the custom build process to build your Addon. The Addon Repository anticipates that you have a build script in your repository. The build script should be invoked by the yarn build --env production command. The Addon Repository will run this command during the build process.
You can use various build tools like Webpack, Gulp, or Grunt to build your Addon. The Addon Repository will run the build script in the root directory of your repository.
The output of the build script should be in the dist folder. The Addon Repository will deploy the contents of the dist folder to the remote server. See the structure bellow on this page.
Provided build process
If you don't have a build script in your repository, you can use the provided build process. See Webpack file, that you can use in your project. Then you have to put a build script in your package.json file.
{
[...]
"scripts": {
"build": "webpack --config webpack.config.js"
[...]
},
[...]
}
Minification:
- CSS and JS files are minified.
- HTML files are also minified.
Asset Copying:
- The
assetsfolder is copied to the remoteassetsfolder as-is.
- The
Minified Files:
- The minified files follow the naming convention:
scripts.header.min.jsfor minified JavaScript in theheaderfolder.styles.header.min.cssfor minified CSS in theheaderfolder.markup.header.min.htmlfor minified HTML in theheaderfolder.
- The minified files follow the naming convention:
Markup Replacement:
- The
markupfield serves as a placeholder for any HTML you place in the textarea.
- The
Directory Structure:
- The
srcfolder can contain subfolders likeheader,footer, andorderFinalecorresponding to three fields in the administration. - All
.js,.css, and.htmlfiles in these subfolders will be minified and deployed in alphabetical order.
- The
Ignored Files:
- Any other files outside the
srcandassetsfolders are ignored during deployment.
- Any other files outside the
These processes ensure that your Addon Repository builds and deploys the necessary files while optimizing them for performance.
Example of the build process. The following folder structure:
my-addon/
├─ assets/
│ ├─ font.ttf
│ ├─ picture.png
└─ src/
├─ footer/
│ ├─ script1.js
│ ├─ script2.js
├─ header/
│ ├─ markup.html
│ ├─ style.css
└─ orderFinale/
└── remarketing.js
will be deployed as:
my-addon/
├─ assets/
│ ├─ font.ttf
│ ├─ picture.png
├─ src/
│ ├─ footer/
│ │ ├─ script1.js
│ │ ├─ script2.js
│ ├─ header/
│ │ ├─ markup.html
│ │ ├─ style.css
│ └─ orderFinale/
│ └── remarketing.js
└── dist/
├── assets/
│ ├── font.ttf
│ └── picture.png
├── markups.header.html
├── scripts.footer.min.js
├── scripts.orderFinale.min.js
└── styles.header.min.css