Encrypt my plugin?

welcome everybody.
can you help me with it?
the code:

// webpack.config.js

const webpack = require('webpack');
const fs = require('fs');
const archiver = require('archiver');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const WebpackObfuscator = require('webpack-obfuscator');
const {version} = require('./package.json');

const triggerAfterBuild = function (cb) {
    this.apply = function (compiler) {
        if (compiler.hooks && compiler.hooks.done) {
            compiler.hooks.done.tap('webpack-arbitrary-code', cb);

module.exports = function (env, argv) {
    const prod = env.production || false;
    const build = prod ? 'dist' : 'local';

    const {pluginId, pluginName} = require('./src/env/config.' + build);
    const {id: pluginIdDev, name: pluginNameDev} = require('./src/manifest.json');
    const path = require('path').resolve(__dirname, 'build/' + build);

    const callbackAfterBuild = function () {
        const manifestFile = `${path}\\manifest.json`;


    return {
        mode: 'production',
        entry: './src/index.js',
        output: {
            path: path,
            filename: 'index.js',
        externals: {
            'uxp': 'commonjs uxp',
            'photoshop': 'commonjs photoshop',
            'locales': 'commonjs locales'
        plugins: [
            new CleanWebpackPlugin(),
            new webpack.NormalModuleReplacementPlugin(
                '../env/config.' + build
            new CopyPlugin({
                patterns: [
                    {from: 'src/icons', to: `${path}/icons`},
                    {from: 'src/locales', to: `${path}/locales`},
                    {from: 'src/manifest.json', to: `${path}/manifest.json`},
            new WebpackObfuscator({
                debugProtection: true,
                disableConsoleOutput: true,
                selfDefending: true,
            new triggerAfterBuild(callbackAfterBuild),

I have a problem
1- archiver.
2- webpack-obfuscator.
3- package.json…
4- use loadash
I’ve tried but my attempts failed :hot_face:

You just plainly copied a sample code of my personal setup. I’m pretty sure most paths don’t match and you probably don’t have all these plugins installed

Yes, it is your code itself, but I could not use it properly. Can you tell me how to install these plugins such as clean-webpack-plugin , copy-webpack-plugin

Sorry, but this already is out of UXP scope and I would suggest to start by going through Webpack documentation. Also, what you’re asking, is a complete fully working packaging solution, which is not possible to implement without knowing your plugin structure. And I very much doubt someone would spend their time just trying to write a full solution for you :thinking:


Thank you, my friend. I will take your words and learn them to create the thing I need. I tried it and followed the private files, but I am confused. I will try several times to find out my mistake and avoid it.
Sorry to bother you


1 Like

I hope that in the near future I will be able to solve the problem