-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathwebpack.config.firebase.ts
51 lines (47 loc) · 1.56 KB
/
webpack.config.firebase.ts
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
import { webpackDefaults } from './config/webpackDefaults'
import { getPath, getMode } from './config/utils'
import nodeExternals from 'webpack-node-externals'
import AssetsWebpackPlugin from 'assets-webpack-plugin'
import CopyWebpackPlugin from 'copy-webpack-plugin'
const mode = getMode()
const isProduction = mode === 'production'
const webConfig = webpackDefaults({
entry: getPath('src/web/index.tsx'),
output: {
filename: isProduction ? '[name]-[chunkhash].js' : '[name].js',
chunkFilename: isProduction ? '[id]-[chunkhash].js' : '[id].js',
path: getPath('build/web/static'),
publicPath: '/static/',
},
target: 'web',
plugins: [
new CopyWebpackPlugin({
patterns: [{ from: getPath('src/static') }],
}),
// @ts-expect-error: I don't want to deal with it right now
...(isProduction
? // Put webpack-assets.json into functions build
// so it knows which JS and CSS file to link in the web page.
[new AssetsWebpackPlugin({ path: getPath('build/functions') })]
: []),
],
})
const functionsConfig = webpackDefaults({
entry: getPath('src/functions/index.ts'),
output: {
filename: 'index.js',
path: getPath('build/functions'),
publicPath: '/static/',
// Expose module.exports from entry for firebase to run
libraryTarget: 'commonjs2',
},
target: 'node',
// Do not bundle all external libraries
externals: [
// @ts-expect-error: I don't want to deal with it right now
nodeExternals({
allowlist: [/\.css\?global$/],
}),
],
})
export default [webConfig, functionsConfig]