-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.render.js
63 lines (59 loc) · 1.66 KB
/
webpack.render.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
const {makeRenderConfig, root} = require('./webpack.common');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
// Render process app
module.exports = function makeWebpackConfig(prodMode) {
const entryFile = path.resolve(__dirname, './src/render/bootstrap.ts');
const indexHtml = 'src/index.html';
let config = makeRenderConfig('render', entryFile, indexHtml, prodMode);
config.plugins.push(
new CopyWebpackPlugin([
{
from: root('src/package.json')
},
{
context: './src',
from: 'assets/icons*/*.woff2',
to: ''
},
{
context: './src',
from: 'node_modules/**/*',
to: ''
},
{
context: './node_modules/three/build',
from: '*.js',
to: 'vendor/three'
},
{
context: './src/library',
from: '**/*',
to: 'library'
}
])
);
return config;
};
function packageSort(packages) {
var len = packages.length - 1;
var first = packages[0];
var last = packages[len];
return function sort(a, b) {
// polyfills always first
if (a.names[0] === first) {
return -1;
}
// main always last
if (a.names[0] === last) {
return 1;
}
// vendor before app
if (a.names[0] !== first && b.names[0] === last) {
return -1;
} else {
return 1;
}
}
}