-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config-audiomanager.js
85 lines (79 loc) · 2.4 KB
/
webpack.config-audiomanager.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const path = require('path')
const webpack = require('webpack')
const nodeExternals = require('webpack-node-externals')
var WebpackObfuscator = require('webpack-obfuscator');
const externalsFunc = nodeExternals();
//const IgnoreDynamicRequire = require('webpack-ignore-dynamic-require');
class IgnoreDynamicRequire {
apply (compiler) {
compiler.hooks.normalModuleFactory.tap('IgnoreDynamicRequire', factory => {
factory.hooks.parser.for('javascript/auto').tap('IgnoreDynamicRequire', (parser, options) => {
parser.hooks.call.for('require').tap('IgnoreDynamicRequire', expression => {
// This is a SyncBailHook, so returning anything stops the parser, and nothing allows to continue
if (expression.arguments.length !== 1 || expression.arguments[0].type === 'Literal') {
return
}
const arg = parser.evaluateExpression(expression.arguments[0])
if (!arg.isString() && !arg.isConditional()) {
return true;
}
});
});
});
}
}
//const HtmlWebPackPlugin = require("html-webpack-plugin")
module.exports = {
mode: 'production',
entry: {
audiomanager: './src/audiomanager.js',
},
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/',
filename: '[name].js'
},
target: 'node',
externals: [
nodeExternals(),
], // Need this to avoid error when working with Express
optimization: {
splitChunks: {
chunks: 'all',
},
},
module: {
rules: [
{
// Transpiles ES6-8 into ES5
test: /\.js$/,
exclude: [
/node_modules/,
path.resolve(__dirname, 'common.js'),
path.resolve(__dirname, "node_modules")
],
/*use: {
loader: "babel-loader"
}*/
enforce: 'post',
use: {
loader: WebpackObfuscator.loader,
options: {
rotateStringArray: true
}
}
},
{ test: /\.pl$/, loader: 'ignore-loader' },
{ test: /\.xml$/, loader: 'ignore-loader' },
{ test: /\.txt$/, loader: 'ignore-loader' },
{ test: /\.sh$/, loader: 'ignore-loader' },
{ test: /\.md$/, loader: 'ignore-loader' },
{ test: /\.pegjs$/, loader: 'ignore-loader' },
{ test: /LICENSE$/, loader: 'ignore-loader' },
{ test: /\.jar$/, loader: 'ignore-loader' },
]
},
plugins: [
new IgnoreDynamicRequire()
],
}