-
Notifications
You must be signed in to change notification settings - Fork 319
/
webpack.config.js
147 lines (144 loc) · 4.77 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
const Path = require("path");
const Webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MergeIntoSingleFilePlugin = require("webpack-merge-and-include-globally");
const CopyPlugin = require("copy-webpack-plugin");
const {merge} = require("webpack-merge");
const runtime = require("./webpack.runtime.js");
const source = Path.resolve(__dirname, "source");
const output = Path.resolve(__dirname, "docs/editor");
module.exports = [
{
context: source,
entry: source + "/editor/Main.js",
target: "web",
devtool: false,
performance: {
hints: false,
},
module: {
rules: [
{
test: /\.glsl$/i,
use: "raw-loader"
},
{
test: /.*brython.*/,
loader: "@shoutem/webpack-prepend-append",
options: JSON.stringify({
prepend: `(function (root, factory) {
if (typeof define === 'function' && define.amd) { define([], factory); } // AMD loader
else if (typeof module === 'object' && module.exports) { module.exports = factory(); } // CommonJS loader
else { root.brython = factory(); } // Script tag
}(typeof self !== 'undefined' ? self : this, function () {
var process = {release: {name: ''}};`,
append: `window.__BRYTHON__ = __BRYTHON__;
return __BRYTHON__;
}));`
})
}
]
},
output: {
hashFunction: "sha256",
filename: "bundle.js",
path: output
},
plugins: [
new CopyPlugin({
patterns: [
{
from: source + "/files",
to: output + "/files",
force: true
}
],
options: {concurrency: 100}
}),
new HtmlWebpackPlugin({template: source + "/editor/index.html", filename: "index.html"}),
new Webpack.ProgressPlugin(),
new Webpack.ProvidePlugin({
THREE: "three",
"window.THREE": "three"
}),
new MergeIntoSingleFilePlugin({
files: {
"package.json": [
"package.json"
],
"styles.css": [
"source/editor/style.css",
"source/editor/theme/dark.css"
],
"draco_encoder.js": [
"source/lib/draco_encoder.js"
],
"jshint.js": [
"node_modules/jshint/dist/jshint.js"
],
"acorn.js": [
"node_modules/acorn/dist/acorn.js",
"node_modules/acorn-loose/dist/acorn-loose.js",
"node_modules/acorn-walk/dist/walk.js"
],
"tern.js": [
"node_modules/tern/lib/signal.js",
"node_modules/tern/lib/tern.js",
"node_modules/tern/lib/def.js",
"node_modules/tern/lib/comment.js",
"node_modules/tern/lib/infer.js",
"node_modules/tern/plugin/doc_comment.js"
],
"codemirror.js": [
"node_modules/codemirror/lib/codemirror.js",
"node_modules/codemirror/keymap/sublime.js",
"node_modules/codemirror/keymap/emacs.js",
"node_modules/codemirror/keymap/vim.js",
"node_modules/codemirror/mode/python/python.js",
"node_modules/codemirror/mode/javascript/javascript.js",
"node_modules/codemirror/mode/css/css.js",
"node_modules/codemirror/mode/xml/xml.js",
"node_modules/codemirror/mode/htmlmixed/htmlmixed.js",
"node_modules/codemirror/addon/edit/closebrackets.js",
"node_modules/codemirror/addon/edit/matchbrackets.js",
"node_modules/codemirror/addon/scroll/annotatescrollbar.js",
"node_modules/codemirror/addon/search/search.js",
"node_modules/codemirror/addon/search/searchcursor.js",
"node_modules/codemirror/addon/search/jump-to-line.js",
"node_modules/codemirror/addon/search/match-highlighter.js",
"node_modules/codemirror/addon/search/matchesonscrollbar.js",
"node_modules/codemirror/addon/hint/show-hint.js",
"node_modules/codemirror/addon/hint/anyword-hint.js",
"node_modules/codemirror/addon/dialog/dialog.js",
"node_modules/codemirror/addon/selection/mark-selection.js",
"node_modules/codemirror/addon/selection/active-line.js",
"node_modules/codemirror/addon/selection/selection-pointer.js",
"node_modules/codemirror/addon/lint/lint.js",
"node_modules/codemirror/addon/lint/javascript-lint.js",
"node_modules/codemirror/addon/tern/tern.js",
"node_modules/codemirror/addon/runmode/colorize.js",
"node_modules/codemirror/addon/runmode/runmode.js"
],
"codemirror.css": [
"node_modules/codemirror/lib/codemirror.css",
"node_modules/codemirror/theme/**/*.css",
"node_modules/codemirror/addon/search/matchesonscrollbar.css",
"node_modules/codemirror/addon/tern/tern.css",
"node_modules/codemirror/addon/dialog/dialog.css",
"node_modules/codemirror/addon/lint/lint.css",
"node_modules/codemirror/addon/hint/show-hint.css"
]
}
})
]
},
merge(runtime[0], {
output: {
hashFunction: "sha256",
filename: "nunu.min.js",
path: output + "/files/runtime",
library: "Nunu",
libraryTarget: "umd"
}
})
];