-
Notifications
You must be signed in to change notification settings - Fork 29.3k
/
extension-browser.webpack.config.js
78 lines (71 loc) · 1.83 KB
/
extension-browser.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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
//@ts-check
'use strict';
const CopyPlugin = require('copy-webpack-plugin');
const Terser = require('terser');
const defaultConfig = require('../shared.webpack.config');
const withBrowserDefaults = defaultConfig.browser;
const browserPlugins = defaultConfig.browserPlugins;
const languages = [
'zh-tw',
'cs',
'de',
'es',
'fr',
'it',
'ja',
'ko',
'pl',
'pt-br',
'ru',
'tr',
'zh-cn',
];
module.exports = withBrowserDefaults({
context: __dirname,
entry: {
extension: './src/extension.browser.ts',
},
plugins: [
...browserPlugins, // add plugins, don't replace inherited
// @ts-ignore
new CopyPlugin({
patterns: [
{
from: '../node_modules/typescript/lib/*.d.ts',
to: 'typescript/',
flatten: true
},
{
from: '../node_modules/typescript/lib/typesMap.json',
to: 'typescript/'
},
...languages.map(lang => ({
from: `../node_modules/typescript/lib/${lang}/**/*`,
to: 'typescript/',
transformPath: (targetPath) => {
return targetPath.replace(/\.\.[\/\\]node_modules[\/\\]typescript[\/\\]lib/, '');
}
}))
],
}),
// @ts-ignore
new CopyPlugin({
patterns: [
{
from: '../node_modules/typescript/lib/tsserver.js',
to: 'typescript/tsserver.web.js',
transform: (content) => {
return Terser.minify(content.toString()).then(output => output.code);
},
transformPath: (targetPath) => {
return targetPath.replace('tsserver.js', 'tsserver.web.js');
}
}
],
}),
],
});