forked from WorldBrain/Memex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
90 lines (79 loc) · 2.24 KB
/
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
import path from 'path'
import initLoaderRules from './loaders'
import initPlugins from './plugins'
import initMinimizers from './minimizers'
import { externalTsModules } from './external'
export const extensions = ['.ts', '.tsx', '.js', '.jsx', '.coffee']
export const entry = {
background: './src/background.ts',
popup: './src/popup/index.tsx',
content_script: './src/content_script.js',
options: './src/options/options.jsx',
twitter: './src/social-integration/twitter/',
}
export const htmlTemplate = path.resolve(__dirname, './template.html')
export const output = {
path: path.resolve(__dirname, '../extension'),
filename: '[name].js',
}
export default ({ context = __dirname, mode = 'development', ...opts }) => {
const aliases = {
src: path.resolve(context, './src'),
}
for (const externalTsModule of externalTsModules) {
const extPath = path.resolve(
context,
`./external/${externalTsModule}/ts`,
)
Object.assign(aliases, {
[`${externalTsModule}$`]: extPath,
[`${externalTsModule}/lib`]: extPath,
})
}
const conf = {
context,
entry,
output,
mode,
devtool:
mode === 'development'
? 'inline-cheap-module-source-map'
: 'hidden-source-map',
plugins: initPlugins({
...opts,
mode,
template: htmlTemplate,
}),
module: {
rules: initLoaderRules({ ...opts, mode, context }),
},
resolve: {
extensions,
symlinks: false,
mainFields: ['browser', 'main', 'module'],
alias: aliases,
},
stats: {
assetsSort: 'size',
children: false,
cached: false,
cachedAssets: false,
entrypoints: false,
excludeAssets: /\.(png|svg)/,
maxModules: 5,
},
performance: {
hints: false,
},
}
if (mode === 'production') {
conf.optimization = {
minimizer: initMinimizers(),
}
}
// CI doesn't need source-maps
if (opts.isCI) {
delete conf.devtool
}
return conf
}