---
title: "Setup zip file in wordPress plugin"
url: "https://www.tarikul.top/wordpress/setup-zip-file-in-wordpress-plugin/"
language: "en-US"
updated: "2024-10-21T10:49:38+00:00"
---

# Setup zip file in wordPress plugin

### Steps to Update the Build Process

#### 1. **Update Grunt Configuration for Copying the Assets Folder**

You can use the `grunt-contrib-compress` and `grunt-contrib-copy` plugins to copy the `assets` folder to the final destination before zipping the plugin.

1. **Install the necessary Grunt plugins**:

```
npm install grunt-contrib-compress grunt-contrib-copy --save-dev
```

#### 2. **Update Grunt Configuration**

You mentioned that the zip file is not being created. To ensure that, update your `gruntfile.js` to ensure proper copying and compressing.

Here’s a simplified example of how to configure Grunt to generate a zip file that includes the `assets` folder:

```
module.exports = function (grunt) {
   'use strict';

   // Load all grunt tasks matching the `grunt-*` pattern.
   require('load-grunt-tasks')(grunt);

   // Show elapsed time.
   require('@lodder/time-grunt')(grunt);

   // Project configuration.
   grunt.initConfig({
      package: grunt.file.readJSON('package.json'),

      // Copy the assets folder to the build directory
      copy: {
         main: {
            expand: true,
            src: ['assets/**', '**/*.php', '!node_modules/**', '!build/**', '!vendor/**'],
            dest: 'build/',
         },
      },

      // Compress (zip) the plugin, including the build directory and excluding the vendor folder
      compress: {
         main: {
            options: {
               archive: 'release/<%= package.name %>.zip',
            },
            files: [
               {
                  expand: true,
                  cwd: 'build/',
                  src: ['**', '!vendor/**'],  // Exclude the vendor folder here
                  dest: '<%= package.name %>/',
               },
            ],
         },
      },
   });

   // Build task: includes copying assets and compressing
   grunt.registerTask('build', ['copy', 'compress']);
};
```

#### 3. **Update Your `package.json` Script**

Ensure your `package.json` is pointing to the correct Grunt task for creating the zip file. Update the `plugin-zip` script in `package.json` to run the `grunt build` task:

```
{
  "scripts": {
    "plugin-zip": "grunt build"
  }
}
```

### 4. **Run the Command**

Run the following command again to build the plugin and create the zip file without the `vendor` folder:

```
npm run plugin-zip
```
