Create Plug-in Files using webpack-plugin-kintone-plugin
Contents
Introduction
This article introduces webpack-plugin-kintone-plugin, a CLI tool designed to create Kintone plug-in files using
webpack
.
It can be used to compress files or bundle third party libraries.
It is available as a npm package on Windows, macOS, and Linux environments.
GitHub
https://github.com/kintone/js-sdk/tree/main/packages/webpack-plugin-kintone-plugin
License
Documentation
https://github.com/kintone/js-sdk/blob/main/packages/webpack-plugin-kintone-plugin/README.md
Installation
Node.js and npm are needed to run webpack-plugin-kintone-plugin.
npm is installed automatically when installing Node.js.
-
Download the installer from the Node.js Official Site
.
Check theengines
property in package.jsonfor the Node.js version requirements.
For example, if the following property is stated, version 18 or higher is required.1 2 3
"engines": { "node": ">=18" },
-
Run the installer and follow the instructions.
Quick Start
Step 1: Prepare the plug-in
This article uses a template created in the Create Plug-in Templates using create-plugin article. Follow the steps in Basic Usage and confirm the directory structure before going to the next step.
To prepare your own package file, follow the steps in the Package Plug-in Files using plugin-packer article.
Step 2: Install Webpack
Install webpack-plugin-kintone-plugin and webpack using the following commands.
|
|
Step 3: Create build directory
Files in the "plugin" directory will be packaged to Kintone plug-in files.
|
|
Step 4: Set up webpack-plugin-kintone-plugin
To run webpack-plugin-kintone-plugin, create and modify the following three files
manifest.json
webpack.config.js
package.json
manifest.json
This is a configuration file for packaging plug-ins.
Move 'src/manifest.json' to the "plugin" directory created in Step 3.
|
|
webpack.config.js
This is a webpack configuration file.
Use the following code and create webpack.config.js
under the "sample_plugin_project" directory created in step 1.
|
|
In addition, to set the plug-in ID and version of the manifest.json as the file name of the generated zip file, use the following code.
|
|
package.json
This is a file for managing npm packages.
Modify the scripts
property in the package.json
as follows.
|
|
Step 5: Move files to "plugin"
Move the css, HTML, and image files to the "plugin" directory for packaging.
|
|
The file tree should now be updated into the following structure:
|
|
Step 6: Package plug-in files
Run the following command to package the files:
|
|
Under the "dist" directory, a plug-in file is generated with the name "plugin.zip".
Step 7: Upload the plug-in
Add the plug-in created to Kintone and use it in the Kintone app.
There are two ways to add plug-ins to Kintone:
Notes
Automatically package and upload plug-ins to Kintone
Run the following command to automatically package and upload the plug-in when the code is modified.
This command is running plugin-uploader.
For more details, refer to the
Upload Plug-in Files using plugin-uploader
article.
|
|