-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
148 lines (140 loc) · 5.57 KB
/
webpack.config.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
const path = require('path');
const MergeIntoSingleFilePlugin = require('webpack-merge-and-include-globally');
const Uglify = require("uglify-js");
const babel = require("@babel/core");
// Blockly
const JS_BLOCKLY_FILES = [
path.resolve(__dirname, '../blockly/blockly_compressed.js'),
path.resolve(__dirname, '../blockly/blocks_compressed.js'),
path.resolve(__dirname, '../blockly/msg/js/en.js'),
path.resolve(__dirname, '../blockly/python_compressed.js')
];
// CodeMirror
const JS_CODEMIRROR_FILES = [
path.resolve(__dirname, 'lib/codemirror/codemirror.js'),
/*path.resolve(__dirname, '../lib/codemirror/show-hint.js'),
path.resolve(__dirname, '../lib/codemirror/python-hint.js'),*/
path.resolve(__dirname, 'lib/codemirror/fullscreen.js'),
path.resolve(__dirname, 'lib/codemirror/python.js'),
];
// Skulpt
const JS_SKULPT_FILES = [
path.resolve(__dirname, '../skulpt/dist/skulpt.js'),
path.resolve(__dirname, '../skulpt/dist/skulpt-stdlib.js'),
];
// Skulpt Parser
const JS_SKULPT_PARSER_FILES = [
path.resolve(__dirname, 'src/skulpt/skulpt_shim.js'),
path.resolve(__dirname, 'src/skulpt/astnodes.js'),
path.resolve(__dirname, 'src/skulpt/token.js'),
path.resolve(__dirname, 'src/skulpt/parse_tables.js'),
path.resolve(__dirname, 'src/skulpt/tokenize.js'),
path.resolve(__dirname, 'src/skulpt/parser.js'),
path.resolve(__dirname, 'src/skulpt/ast.js'),
];
// BlockMirror
const JS_BLOCKMIRROR_FILES = [
path.resolve(__dirname, 'src/blockly_shims.js'),
path.resolve(__dirname, 'src/block_mirror.js'),
path.resolve(__dirname, 'src/text_editor.js'),
path.resolve(__dirname, 'src/block_editor.js'),
path.resolve(__dirname, 'src/text_to_blocks.js'),
path.resolve(__dirname, 'src/ast/ast_functions.js'),
path.resolve(__dirname, 'src/toolbars.js'),
// AST Handlers
path.resolve(__dirname, 'src/ast/ast_For.js'),
path.resolve(__dirname, 'src/ast/ast_If.js'),
path.resolve(__dirname, 'src/ast/ast_While.js'),
path.resolve(__dirname, 'src/ast/ast_Num.js'),
path.resolve(__dirname, 'src/ast/ast_BinOp.js'),
path.resolve(__dirname, 'src/ast/ast_Name.js'),
path.resolve(__dirname, 'src/ast/ast_Assign.js'),
path.resolve(__dirname, 'src/ast/ast_AnnAssign.js'),
path.resolve(__dirname, 'src/ast/ast_AugAssign.js'),
path.resolve(__dirname, 'src/ast/ast_Str.js'),
path.resolve(__dirname, 'src/ast/ast_Expr.js'),
path.resolve(__dirname, 'src/ast/ast_UnaryOp.js'),
path.resolve(__dirname, 'src/ast/ast_BoolOp.js'),
path.resolve(__dirname, 'src/ast/ast_Compare.js'),
path.resolve(__dirname, 'src/ast/ast_Assert.js'),
path.resolve(__dirname, 'src/ast/ast_NameConstant.js'),
path.resolve(__dirname, 'src/ast/ast_List.js'),
path.resolve(__dirname, 'src/ast/ast_Tuple.js'),
path.resolve(__dirname, 'src/ast/ast_Set.js'),
path.resolve(__dirname, 'src/ast/ast_Dict.js'),
path.resolve(__dirname, 'src/ast/ast_Starred.js'),
path.resolve(__dirname, 'src/ast/ast_IfExp.js'),
path.resolve(__dirname, 'src/ast/ast_Attribute.js'),
path.resolve(__dirname, 'src/ast/ast_Call.js'),
path.resolve(__dirname, 'src/ast/ast_Raise.js'),
path.resolve(__dirname, 'src/ast/ast_Delete.js'),
path.resolve(__dirname, 'src/ast/ast_Subscript.js'),
path.resolve(__dirname, 'src/ast/ast_Comp.js'),
path.resolve(__dirname, 'src/ast/ast_FunctionDef.js'),
path.resolve(__dirname, 'src/ast/ast_Lambda.js'),
path.resolve(__dirname, 'src/ast/ast_Return.js'),
path.resolve(__dirname, 'src/ast/ast_Yield.js'),
path.resolve(__dirname, 'src/ast/ast_YieldFrom.js'),
path.resolve(__dirname, 'src/ast/ast_Global.js'),
<!--src/ast/ast_Nonlocal.js-->
path.resolve(__dirname, 'src/ast/ast_Break.js'),
path.resolve(__dirname, 'src/ast/ast_Continue.js'),
path.resolve(__dirname, 'src/ast/ast_Try.js'),
path.resolve(__dirname, 'src/ast/ast_ClassDef.js'),
path.resolve(__dirname, 'src/ast/ast_Import.js'),
path.resolve(__dirname, 'src/ast/ast_With.js'),
path.resolve(__dirname, 'src/ast/ast_Comment.js'),
path.resolve(__dirname, 'src/ast/ast_Raw.js')
];
const JS_FILES = [].concat(JS_BLOCKLY_FILES, JS_CODEMIRROR_FILES, JS_SKULPT_FILES,
JS_BLOCKMIRROR_FILES)
const babelify = code =>
babel.transform(code, {
presets: ["@babel/preset-env"]
}).code;
const config = {
entry: [
path.resolve(__dirname, 'src/main.js'),
],
output: {
path: __dirname + '/dist',
filename: 'block_mirror.js',
library: 'BlockMirror'
},
module: {
rules: [
{
test: /(\.jsx|\.js)$/,
loader: "babel-loader",
exclude: /(node_modules|bower_components)/
},
]
},
resolve: {
extensions: ['.js']
},
plugins: [
new MergeIntoSingleFilePlugin({
files: {
"skulpt_parser.js": JS_SKULPT_PARSER_FILES,
"block_mirror.js": JS_BLOCKMIRROR_FILES,
"block_mirror.css": [
/*path.resolve(__dirname, 'lib/codemirror/codemirror.css'),
path.resolve(__dirname, 'lib/codemirror/fullscreen.css'),
path.resolve(__dirname, 'lib/codemirror/show-hint.css'),*/
path.resolve(__dirname, 'src/block_mirror.css'),
],
},
transform: {
"skulpt_parser.js":babelify,
"block_mirror.js":babelify
}
})
]
/*devServer: {
port: 3000,
contentBase: __dirname + '/dist',
inline: true
}*/
};
module.exports = config;