-
Notifications
You must be signed in to change notification settings - Fork 283
/
webpack.config.js
127 lines (124 loc) · 3.04 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
const path = require('path');
const webpack = require('webpack');
const fs = require('fs');
const generateCSSScopedName = require('./build/cssScoopeGenerator')();
const libAssets = require('./build/libAssets');
const WEB_APP = path.join(__dirname, 'web/app');
const MODULES = path.join(__dirname, 'modules');
const NODE_MODULES = path.join(__dirname, 'node_modules');
const INTEGRATION_TESTS = path.join(__dirname, 'web/test');
const GLOBAL_CSS = path.join(__dirname, 'web/css');
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: {
index: ['babel-polyfill', './web/app/index'],
sketcher: ['babel-polyfill', './web/app/sketcher']
},
output: {
path: path.join(__dirname, 'dist/static'),
filename: '[name].bundle.js',
chunkFilename: '[id].bundle.js',
publicPath: '/static/'
},
externals: {
'verb-nurbs': 'verb'
},
resolve: {
extensions: ['.js', '.jsx', ".ts", ".tsx"],
modules: [MODULES, "node_modules", WEB_APP],
},
devServer: {
hot: false,
liveReload: false,
client: false,
static: [
path.join(__dirname, 'web'),
],
setupMiddlewares(middlewares, devServer) {
libAssets.forEach(asset => {
devServer.app.get(`/lib-assets/${asset}`, function (req, res) {
res.sendFile(path.join(NODE_MODULES, asset))
})
});
return middlewares;
}
},
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/,
loader: 'babel-loader',
include: [MODULES, WEB_APP, INTEGRATION_TESTS]
},
{
test: /\.(less|css)$/,
include: [GLOBAL_CSS, INTEGRATION_TESTS],
use: [
'style-loader',
'css-loader?-url',
'less-loader',
]
},
{
test: /\.(css)$/,
include: [NODE_MODULES],
use: [
'style-loader',
'css-loader',
]
},
{
oneOf: [
{
test: /\.(less|css)$/,
include: [path.resolve(MODULES, 'ui/styles/global')],
use: [
'style-loader',
'css-loader',
'less-loader'
]
},
{
test: /\.(less|css)$/,
include: [MODULES, WEB_APP],
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: {
mode: 'local',
getLocalIdent: (context, localIdentName, localName) => generateCSSScopedName(localName, context.resourcePath),
},
url: false
}
},
'less-loader'
]
}
],
},
{
test: /\.wasm$/,
type: "javascript/auto",
loader: "file-loader"
},
{
test: /\.svg$/,
loader: 'raw-loader'
},
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader'
},
],
},
]
},
node: {
__dirname: true
}
};