2020-08-29 05:46:48 +03:00
|
|
|
/**
|
|
|
|
* webpack.config-cli.js
|
|
|
|
* Copyright: Microsoft 2018
|
|
|
|
*/
|
|
|
|
|
|
|
|
const path = require('path');
|
|
|
|
const CopyPlugin = require('copy-webpack-plugin');
|
|
|
|
const { TsconfigPathsPlugin } = require('tsconfig-paths-webpack-plugin');
|
2021-06-02 22:18:10 +03:00
|
|
|
const { cacheConfig, monorepoResourceNameMapper } = require('../../build/lib/webpack');
|
2020-08-29 05:46:48 +03:00
|
|
|
|
|
|
|
const outPath = path.resolve(__dirname, 'dist');
|
|
|
|
const typeshedFallback = path.resolve(__dirname, '..', 'pyright-internal', 'typeshed-fallback');
|
|
|
|
|
2020-12-09 23:37:21 +03:00
|
|
|
/**@type {(env: any, argv: { mode: 'production' | 'development' | 'none' }) => import('webpack').Configuration}*/
|
|
|
|
module.exports = (_, { mode }) => {
|
|
|
|
return {
|
|
|
|
context: __dirname,
|
|
|
|
entry: {
|
|
|
|
extension: './src/extension.ts',
|
|
|
|
server: './src/server.ts',
|
|
|
|
},
|
|
|
|
target: 'node',
|
|
|
|
output: {
|
|
|
|
filename: '[name].js',
|
|
|
|
path: outPath,
|
|
|
|
libraryTarget: 'commonjs2',
|
|
|
|
devtoolModuleFilenameTemplate:
|
|
|
|
mode === 'development' ? '../[resource-path]' : monorepoResourceNameMapper('vscode-pyright'),
|
2021-05-05 01:04:01 +03:00
|
|
|
clean: true,
|
2020-12-09 23:37:21 +03:00
|
|
|
},
|
|
|
|
devtool: mode === 'development' ? 'source-map' : 'nosources-source-map',
|
2021-06-16 04:50:46 +03:00
|
|
|
cache: mode === 'development' ? cacheConfig(__dirname, __filename) : false,
|
2020-12-09 23:37:21 +03:00
|
|
|
stats: {
|
|
|
|
all: false,
|
|
|
|
errors: true,
|
|
|
|
warnings: true,
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.ts', '.js'],
|
|
|
|
plugins: [
|
|
|
|
new TsconfigPathsPlugin({
|
2020-12-15 02:13:10 +03:00
|
|
|
configFile: 'tsconfig.withBaseUrl.json', // TODO: Remove once the plugin understands TS 4.1's implicit baseUrl.
|
2020-12-09 23:37:21 +03:00
|
|
|
extensions: ['.ts', '.js'],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
externals: {
|
|
|
|
vscode: 'commonjs vscode',
|
|
|
|
fsevents: 'commonjs2 fsevents',
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
loader: 'ts-loader',
|
|
|
|
options: {
|
|
|
|
configFile: 'tsconfig.json',
|
|
|
|
},
|
2020-08-29 05:46:48 +03:00
|
|
|
},
|
2020-12-09 23:37:21 +03:00
|
|
|
],
|
|
|
|
},
|
2021-05-05 01:04:01 +03:00
|
|
|
plugins: [new CopyPlugin({ patterns: [{ from: typeshedFallback, to: 'typeshed-fallback' }] })],
|
2020-12-09 23:37:21 +03:00
|
|
|
};
|
2020-08-29 05:46:48 +03:00
|
|
|
};
|