dutiyesh / dutiyesh/chrome-extension-cli

webpack-obfuscator

Open
#59 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.5k
Forks
105
PR merge metrics
No merged PRs in 30d

Description

I tried to add the webpack-obfuscator plugin, when it was run there was no problem, but if the extension was run there was an error, no specific variable was found.

this my code webpack.common.js

'use strict';

const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WebpackObfuscator = require('webpack-obfuscator');

const PATHS = require('./paths');

// used in the module rules and in the stats exlude list
const IMAGE_TYPES = /\.(png|jpe?g|gif|svg)$/i;

// To re-use webpack configuration across templates,
// CLI maintains a common webpack configuration file - `webpack.common.js`.
// Whenever user creates an extension, CLI adds `webpack.common.js` file
// in template's `config` folder
const common = {
output: {
// the build folder to output bundles and assets in.
path: PATHS.build,
// the filename template for entry chunks
filename: '[name].js',
},
stats: {
all: false,
errors: true,
builtAt: true,
assets: true,
excludeAssets: [IMAGE_TYPES],
},
module: {
rules: [
// Help webpack in understanding CSS files imported in .js files
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
// Check for images imported in .js files and
{
test: IMAGE_TYPES,
use: [
{
loader: 'file-loader',
options: {
outputPath: 'images',
name: '[name].[ext]',
},
},
],
},
{
enforce: 'post',
use: {
loader: WebpackObfuscator.loader,
options: {
reservedStrings: [ '\s*' ],
rotateStringArray: true
}
}
}
],
},
plugins: [
// Copy static assets from `public` folder to `build` folder
new CopyWebpackPlugin({
patterns: [
{
from: '**/*',
context: 'public',
},
],
}),
// Extract CSS into separate files
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new WebpackObfuscator({
rotateStringArray: true,
reservedStrings: [ '\s*' ]
}, [])
],
};

module.exports = common;

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.