Skip to content

Commit edc9685

Browse files
authored
Bring back webpack config (#1897)
1 parent 01c52f7 commit edc9685

File tree

4 files changed

+113
-2
lines changed

4 files changed

+113
-2
lines changed

client/webpack.config.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
//@ts-check
7+
8+
'use strict';
9+
10+
const withDefaults = require('../shared.webpack.config');
11+
const path = require('path');
12+
13+
module.exports = withDefaults({
14+
context: path.join(__dirname),
15+
entry: {
16+
extension: './src/extension.ts',
17+
},
18+
resolve: {
19+
symlinks: false
20+
},
21+
output: {
22+
filename: 'extension.js',
23+
path: path.join(__dirname, 'out')
24+
}
25+
});

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-eslint",
33
"displayName": "ESLint",
44
"description": "Integrates ESLint JavaScript into VS Code.",
5-
"version": "3.0.10",
5+
"version": "3.0.11",
66
"author": "Microsoft Corporation",
77
"license": "MIT",
88
"repository": {
@@ -628,7 +628,9 @@
628628
]
629629
},
630630
"scripts": {
631-
"vscode:prepublish": "npm run esbuild",
631+
"vscode:prepublish": "npm run webpack",
632+
"webpack": "npm run clean && webpack --mode production --config ./client/webpack.config.js && webpack --mode production --config ./server/webpack.config.js",
633+
"webpack:dev": "npm run clean && webpack --mode none --config ./client/webpack.config.js && webpack --mode none --config ./server/webpack.config.js",
632634
"esbuild": "npm run clean && node ./esbuild.js",
633635
"compile": "tsc -b",
634636
"compile:client": "tsc -b ./client/tsconfig.json",

server/webpack.config.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
//@ts-check
7+
8+
'use strict';
9+
10+
const withDefaults = require('../shared.webpack.config');
11+
const path = require('path');
12+
13+
module.exports = withDefaults({
14+
context: path.join(__dirname),
15+
entry: {
16+
extension: './src/eslintServer.ts',
17+
},
18+
resolve: {
19+
symlinks: false
20+
},
21+
output: {
22+
filename: 'eslintServer.js',
23+
path: path.join(__dirname, 'out')
24+
}
25+
});

shared.webpack.config.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
//@ts-check
7+
/** @typedef {import('webpack').Configuration} WebpackConfig **/
8+
9+
'use strict';
10+
11+
const path = require('path');
12+
const merge = require('merge-options');
13+
14+
module.exports = function withDefaults(/**@type WebpackConfig*/extConfig) {
15+
16+
/** @type WebpackConfig */
17+
let defaultConfig = {
18+
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
19+
target: 'node', // extensions run in a node context
20+
node: {
21+
__dirname: false // leave the __dirname-behaviour intact
22+
},
23+
resolve: {
24+
conditionNames: ['import', 'require', 'node'],
25+
mainFields: ['module', 'main'],
26+
extensions: ['.ts', '.js'] // support ts-files and js-files
27+
},
28+
module: {
29+
rules: [{
30+
test: /\.ts$/,
31+
exclude: /node_modules/,
32+
use: [{
33+
// configure TypeScript loader:
34+
// * enable sources maps for end-to-end source maps
35+
loader: 'ts-loader',
36+
options: {
37+
compilerOptions: {
38+
"sourceMap": true,
39+
}
40+
}
41+
}]
42+
}]
43+
},
44+
externals: {
45+
'vscode': 'commonjs vscode', // ignored because it doesn't exist
46+
},
47+
output: {
48+
// all output goes into `dist`.
49+
// packaging depends on that and this must always be like it
50+
filename: '[name].js',
51+
path: path.join(extConfig.context, 'out'),
52+
libraryTarget: "commonjs",
53+
},
54+
// yes, really source maps
55+
devtool: 'source-map'
56+
};
57+
58+
return merge(defaultConfig, extConfig);
59+
};

0 commit comments

Comments
 (0)