Merge pull request #18 from seriousben/obfuscation

obfuscating code
This commit is contained in:
Benjamin Boudreau 2018-06-09 09:50:46 -04:00 committed by GitHub
commit 678a0baa6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 402 additions and 6 deletions

View File

@ -56,11 +56,11 @@ $ npm run build
- [x] Minified - [x] Minified
- [x] Add greenkeeper - [x] Add greenkeeper
- [x] Bookmarklet - [x] Bookmarklet
- [ ] Reset / Cleanslate / No-conflicts of styles - [x] Reset / Cleanslate / No-conflicts of styles
- [ ] Obfuscation - [x] Obfuscation
- [ ] Integrate eslint with webpack
- [ ] Theming support - [ ] Theming support
- [ ] Storyboard and docs - [ ] Storyboard and docs
- [ ] Integrate eslint with webpack
## Background ## Background

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',
{ {