-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
84 lines (77 loc) · 2.97 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
import path from 'path'
import { fileURLToPath } from 'url'
import ESLintPlugin from 'eslint-webpack-plugin'
import { GitRevisionPlugin } from 'git-revision-webpack-plugin'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import webpack from 'webpack'
import { SW_NAME, SW_CORE_NAME } from './src/constants.js'
const gitPlugin = new GitRevisionPlugin({
commithashCommand: 'rev-parse --short HEAD'
})
const __dirname = fileURLToPath(path.dirname(import.meta.url))
const abspath = p => path.resolve(__dirname, p)
const cl = console.log
const devServerPort = 8030
export default (env, { mode }) => {
// Switch to .env files once this gets unwieldy
const e = process.env
const STATIC_FILE_ORIGIN = e.STATIC_FILE_ORIGIN ?? `http://localhost:${devServerPort}`
const L1_ORIGIN = e.L1_ORIGIN ?? 'https://l1s.saturn-test.ms'
const TRUSTED_L1_ORIGIN = e.TRUSTED_L1_ORIGIN ?? 'https://saturn-test.ms'
const LOG_INGESTOR_URL = e.LOG_INGESTOR_URL ?? 'https://p6wofrb2zgwrf26mcxjpprivie0lshfx.lambda-url.us-west-2.on.aws'
const JWT_AUTH_URL = e.JWT_AUTH_URL ?? 'https://fz3dyeyxmebszwhuiky7vggmsu0rlkoy.lambda-url.us-west-2.on.aws'
const ORCHESTRATOR_URL = e.ORCHESTRATOR_URL ?? 'https://orchestrator.strn-test.pl/nodes?maxNodes=100'
return {
// Uncomment snapshot for webpack to detect edits in node_modules/
snapshot: {
managedPaths: [],
},
entry: {
widget: abspath('src/widget/widget.js'),
[SW_NAME]: abspath('src/sw/saturn-sw.js'),
[SW_CORE_NAME]: abspath('src/sw/saturn-sw-core.js'),
},
devServer: {
client: {
logging: 'warn'
},
static: abspath('dist'),
port: devServerPort,
// hot: false,
// liveReload: false,
webSocketServer: false
},
output: {
path: abspath('dist'),
clean: true,
publicPath: STATIC_FILE_ORIGIN + '/',
},
plugins: [
new webpack.EnvironmentPlugin({
COMMITHASH: JSON.stringify(gitPlugin.commithash()),
STATIC_FILE_ORIGIN,
L1_ORIGIN,
TRUSTED_L1_ORIGIN,
LOG_INGESTOR_URL,
JWT_AUTH_URL,
ORCHESTRATOR_URL,
}),
new ESLintPlugin({
emitError: false,
emitWarning: false,
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: abspath('public/index.html'),
// chunks = [] disables script injection, the script tag is
// already present in the html template with an absolute url
chunks: [],
templateParameters: {
// Arc prod client key
CLIENT_KEY: '1205a0fe-142c-40a2-a830-8bbaf6382c3f',
STATIC_FILE_ORIGIN,
}
})
],
}
}