obfuscating code

This commit is contained in:
Benjamin Boudreau 2018-06-09 09:47:19 -04:00
parent ae9652c516
commit b8043a50c7
3 changed files with 399 additions and 3 deletions

392
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
"description": "building an embeddable js widget with react", "description": "building an embeddable js widget with react",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "webpack-cli --mode production", "build": "NODE_ENV=production webpack-cli --mode production",
"start": "webpack-serve --config ./webpack.config.js --mode development --open", "start": "webpack-serve --config ./webpack.config.js --mode development --open",
"test": "jest", "test": "jest",
"test-update-snapshots": "jest --updateSnapshot", "test-update-snapshots": "jest --updateSnapshot",
@ -76,6 +76,7 @@
"style-loader": "^0.21.0", "style-loader": "^0.21.0",
"webpack": "^4.8.3", "webpack": "^4.8.3",
"webpack-cli": "^3.0.1", "webpack-cli": "^3.0.1",
"webpack-obfuscator": "^0.16.0",
"webpack-serve": "^1.0.2" "webpack-serve": "^1.0.2"
}, },
"dependencies": { "dependencies": {

View File

@ -1,6 +1,7 @@
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin'); const CleanWebpackPlugin = require('clean-webpack-plugin');
const increaseSpecificity = require('postcss-increase-specificity'); const increaseSpecificity = require('postcss-increase-specificity');
const JavaScriptObfuscator = require('webpack-obfuscator');
const devMode = process.env.NODE_ENV !== 'production'; const devMode = process.env.NODE_ENV !== 'production';
@ -14,7 +15,8 @@ const defaultConfig = {
filename: devMode ? '[name].css' : '[name].[hash].css', filename: devMode ? '[name].css' : '[name].[hash].css',
chunkFilename: devMode ? '[id].css' : '[id].[hash].css', chunkFilename: devMode ? '[id].css' : '[id].[hash].css',
}), }),
], devMode ? null : new JavaScriptObfuscator(),
].filter(i => i),
module: { module: {
rules: [ rules: [
{ {
@ -26,7 +28,8 @@ const defaultConfig = {
test: /\.(scss|css)$/, test: /\.(scss|css)$/,
use: [ use: [
// fallback to style-loader in development // fallback to style-loader in development
devMode ? 'style-loader' : MiniCssExtractPlugin.loader, // devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'style-loader',
'css-loader', 'css-loader',
'cssimportant-loader', 'cssimportant-loader',
{ {