-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.babel.js
93 lines (90 loc) · 2.56 KB
/
webpack.config.babel.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
/* eslint-disable import/no-extraneous-dependencies */
// Used for development build.
import path from 'path';
const webpack = require('webpack');
export default {
mode: 'development',
output: {
path: path.resolve(__dirname, 'djAerolith/static/dist/'),
filename: '[name].js',
publicPath: '/static/dist/',
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/,
loader: 'babel-loader',
exclude: [/node_modules/],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
alias: {
wordvaultapp: path.resolve(__dirname, './frontend/src/'),
wordwallsapp: path.resolve(__dirname, './djAerolith/wordwalls/static/js/wordwalls/'),
// For the legacy app, make "react" resolve to a single
// node_modules. This is important for hook usage. The "frontend"
// directory, with a newer TS app + Vite, has its own React.
// The legacy app imports some code from this frontend directory
// (see "wordvaultapp" imports in the legacy app). We want
// them to share the same React.
react: path.resolve(__dirname, './node_modules/react'),
},
// alias: {
// // this alias is needed for the auto-generated RPC file import.
// './rpc/wordsearcher': path.resolve(
// __dirname,
// './djAerolith/wordwalls/static/js/wordwalls/gen/rpc/wordsearcher',
// ),
// },
},
entry: {
wordwallsapp: [
'@babel/polyfill',
'promise-polyfill',
'whatwg-fetch',
'./djAerolith/wordwalls/static/js/wordwalls/index',
],
flashcardsapp: ['./djAerolith/flashcards/static/js/flashcards/main'],
},
optimization: {
splitChunks: {
name: (module, chunks, cacheGroupKey) => `${cacheGroupKey}~${chunks.map((c) => c.name).join('~')}`,
cacheGroups: {
node_vendors: {
test: /[\\/]node_modules[\\/]/, // is backslash for windows?
chunks: 'all',
priority: 1,
},
},
},
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),
],
devServer: {
port: 7000,
host: '0.0.0.0',
headers: {
'Access-Control-Allow-Origin': '*',
},
allowedHosts: ['aerolith.localhost'],
client: {
webSocketURL: 'ws://aerolith.localhost/ws',
},
},
watchOptions: {
aggregateTimeout: 300,
poll: 5000,
},
};
// https://medium.com/@andyccs/webpack-and-docker-for-development-and-deployment-ae0e73243db4