mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Added base web version
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const fs = require('fs');
|
||||
|
||||
const copyright = 'Copyright (C) 2016-2018 Timofey Kachalov <sanex3339@yandex.ru>';
|
||||
|
||||
class WebpackUtils {
|
||||
/**
|
||||
* @param entries
|
||||
* @returns {string[]}
|
||||
*/
|
||||
static getBannerText (...entries) {
|
||||
const lineSeparator = '\n\n';
|
||||
|
||||
return entries.reduce((bannerText, entry) => {
|
||||
return `${bannerText}${entry}${lineSeparator}`
|
||||
}, '');
|
||||
}
|
||||
|
||||
static getLicenseText () {
|
||||
return `/*!\n${copyright}\n\n` +
|
||||
fs.readFileSync('./LICENSE.BSD', 'utf8') + "\n*/";
|
||||
}
|
||||
|
||||
static getSourceMapSupportImport () {
|
||||
return `require("source-map-support").install();`;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.WebpackUtils = WebpackUtils;
|
||||
@@ -0,0 +1,65 @@
|
||||
'use strict';
|
||||
|
||||
const nodeExternals = require('webpack-node-externals');
|
||||
const webpack = require('webpack');
|
||||
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
|
||||
const TSLintPlugin = require('tslint-webpack-plugin');
|
||||
const packageJson = require('pjson');
|
||||
|
||||
const WebpackUtils = require('./utils/WebpackUtils').WebpackUtils;
|
||||
|
||||
module.exports = {
|
||||
devtool: 'source-map',
|
||||
entry: {
|
||||
'index': './index.ts',
|
||||
'index.cli': './index.cli.ts'
|
||||
},
|
||||
target: 'node',
|
||||
externals: [nodeExternals()],
|
||||
module: {
|
||||
exprContextCritical: false,
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts(x?)$/,
|
||||
loader: 'awesome-typescript-loader',
|
||||
query: {
|
||||
useBabel: true,
|
||||
babelCore: '@babel/core',
|
||||
useCache: true,
|
||||
forceIsolatedModules: true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts']
|
||||
},
|
||||
plugins: [
|
||||
new webpack.BannerPlugin(
|
||||
{
|
||||
banner: WebpackUtils.getBannerText(
|
||||
WebpackUtils.getLicenseText(),
|
||||
WebpackUtils.getSourceMapSupportImport()
|
||||
),
|
||||
raw: true,
|
||||
entryOnly: false
|
||||
}
|
||||
),
|
||||
new webpack.EnvironmentPlugin({
|
||||
VERSION: packageJson.version
|
||||
}),
|
||||
new CheckerPlugin(),
|
||||
new TSLintPlugin({
|
||||
files: ['./src/**/*.ts'],
|
||||
project: './tsconfig.json',
|
||||
exclude: []
|
||||
})
|
||||
],
|
||||
output: {
|
||||
libraryTarget: 'commonjs2',
|
||||
library: 'JavaScriptObfuscator'
|
||||
},
|
||||
stats: {
|
||||
maxModules: 0
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
|
||||
const webpack = require('webpack');
|
||||
const packageJson = require('pjson');
|
||||
|
||||
const WebpackUtils = require('./utils/WebpackUtils').WebpackUtils;
|
||||
|
||||
module.exports = {
|
||||
devtool: 'source-map',
|
||||
entry: {
|
||||
'index': './index.ts'
|
||||
},
|
||||
target: 'web',
|
||||
module: {
|
||||
exprContextCritical: false,
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts(x?)$/,
|
||||
loader: 'awesome-typescript-loader',
|
||||
query: {
|
||||
useBabel: true,
|
||||
babelCore: '@babel/core',
|
||||
useCache: true,
|
||||
forceIsolatedModules: true,
|
||||
configFileName: 'tsconfig.web.json'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js']
|
||||
},
|
||||
plugins: [
|
||||
new webpack.BannerPlugin(
|
||||
{
|
||||
banner: WebpackUtils.getBannerText(WebpackUtils.getLicenseText()),
|
||||
raw: true,
|
||||
entryOnly: false
|
||||
}
|
||||
),
|
||||
new webpack.EnvironmentPlugin({
|
||||
VERSION: packageJson.version
|
||||
})
|
||||
],
|
||||
output: {
|
||||
libraryTarget: 'var',
|
||||
library: 'JavaScriptObfuscator',
|
||||
filename: 'index.web.js'
|
||||
},
|
||||
performance: {
|
||||
hints: false
|
||||
},
|
||||
stats: {
|
||||
maxModules: 0,
|
||||
warnings: false
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user