-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathwebpack.config.js
More file actions
114 lines (104 loc) · 3.13 KB
/
webpack.config.js
File metadata and controls
114 lines (104 loc) · 3.13 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
const path = require('path');
const webpack = require('webpack');
const shell = require('shelljs');
const chalk = require('chalk');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const GitRevisionPlugin = require('git-revision-webpack-plugin');
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const git = new GitRevisionPlugin({branch: true});
const styleexcludes = [
"node_modules",
"support",
"gen",
"tokenize.js",
"symtable.js",
"compile.js",
"ast.js",
"internalpython.js",
"tigerpython-parser.js",
];
if (!shell.which('git')) {
console.log(chalk.red("WARNING: Cannot find git! Unsure if working directory is clean."));
}
var output = shell.exec('git diff-index --quiet HEAD');
if (output.code !== 0) {
console.log(chalk.red("WARNING: Working directory is not clean."));
} else {
console.log("Working directory is clean.");
}
module.exports = (env, argv) => {
var opt = {
minimize: false
};
var outfile = 'skulpt.js';
var assertfile = './assert-dev.js';
var mod = {};
var languageOut = (env && env.languageOut) || '';
var extraPlugins = [];
if (argv.mode === 'production') {
opt = {
emitOnErrors: false,
minimize: true,
};
outfile = 'skulpt.min.js';
assertfile = './assert-prod.js';
extraPlugins = [new ESLintPlugin({
extensions: ["js"],
exclude: styleexcludes,
overrideConfig: {
rules: {
"brace-style": "off",
"semi": "off",
"indent": "off",
"curly": "off",
"quotes": "off",
},
},
})];
}
var config = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: outfile
},
devtool: 'source-map',
plugins: [
new CleanWebpackPlugin(),
new CopyWebpackPlugin({
patterns: [
{ from: 'debugger/debugger.js', to: 'debugger.js' }
],
}),
new webpack.DefinePlugin({
GITVERSION: JSON.stringify(git.version()),
GITHASH: JSON.stringify(git.commithash()),
GITBRANCH: JSON.stringify(git.branch()),
BUILDDATE: JSON.stringify(new Date())
}),
new CompressionWebpackPlugin({
include: /^skulpt\.min\.js$/,
algorithm: 'gzip'
}),
...extraPlugins,
],
optimization: opt,
performance: {
maxAssetSize: 1400000,
maxEntrypointSize: 1400000,
},
resolve: {
alias: {
'assert': assertfile,
}
},
module: mod,
// uncomment this while working on closure compiler errors
// externals: {
// jsbi: "JSBI",
// }
};
return config;
};