This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathwebpack.config.ts
84 lines (76 loc) · 2.01 KB
/
webpack.config.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
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 { getConfig } from '../../../packages/shared/src/webpack/config';
import { getExtensionConfig } from '../../../packages/shared/src/webpack/extension.config';
import {
CopyWebpackPlugin,
HTMLWebpackPlugin,
} from '../../../packages/shared/src/webpack/plugins';
import packageJson from './package.json';
import { AppEnv } from './src/AppEnv';
process.env.VERSION = packageJson.version.replace('-beta', '');
const { buildENV, ...config } = getConfig({
cwd: __dirname,
target: 'web',
outputDir: path.resolve(__dirname, 'build/dashboard'),
env: AppEnv,
hot: true,
entry: {
dashboard: path.resolve(__dirname, 'src/dashboard.tsx'),
},
});
config.plugins.push(
new HTMLWebpackPlugin({
inject: 'head',
template: path.resolve('./public/index.html'),
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, 'public'),
filter: (file: string) => {
const { base } = path.parse(file);
return !['manifest.json', 'popup.html', 'index.html'].includes(base);
},
},
],
})
);
const { buildENV: extensionBuildEnv, ...extensionConfig } = getExtensionConfig(
'ycai',
{
cwd: __dirname,
env: AppEnv,
manifestVersion: process.env.VERSION,
outputDir: path.resolve(__dirname, 'build/extension'),
distDir: path.resolve(__dirname, 'build/extension'),
transformManifest: (manifest) => {
if (config.mode === 'development') {
manifest.permissions = [
'http://localhost:9000/',
...manifest.permissions,
];
}
if (buildENV.BUNDLE_TARGET === 'chrome') {
manifest.cross_origin_embedder_policy = {
value: 'require-corp',
};
manifest.cross_origin_opener_policy = {
value: 'same-origin',
};
}
return manifest;
},
}
);
export default [
extensionConfig,
{
...config,
devtool: 'source-map',
devServer: {
host: '0.0.0.0',
port: 3000,
hot: true,
},
},
];