mirror of
https://github.com/Microsoft/vscode
synced 2024-10-04 02:14:06 +00:00
polish webpack configs
This commit is contained in:
parent
7ded90e452
commit
cde5781978
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
const withDefaults = require('../shared.webpack.config');
|
const withDefaults = require('../shared.webpack.config');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const webpack = require('webpack');
|
|
||||||
|
|
||||||
const config = withDefaults({
|
const config = withDefaults({
|
||||||
context: path.join(__dirname, 'client'),
|
context: path.join(__dirname, 'client'),
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
const withDefaults = require('../../shared.webpack.config');
|
const withDefaults = require('../../shared.webpack.config');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const webpack = require('webpack');
|
|
||||||
|
|
||||||
const config = withDefaults({
|
const config = withDefaults({
|
||||||
context: path.join(__dirname),
|
context: path.join(__dirname),
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
const withDefaults = require('../shared.webpack.config');
|
const withDefaults = require('../shared.webpack.config');
|
||||||
|
|
||||||
module.exports = withDefaults({
|
module.exports = withDefaults({
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const withDefaults = require('../shared.webpack.config');
|
const withDefaults = require('../shared.webpack.config');
|
||||||
|
|
||||||
module.exports = withDefaults({
|
module.exports = withDefaults({
|
||||||
|
|
|
@ -64,13 +64,13 @@ function withNodeDefaults(/**@type WebpackConfig*/extConfig) {
|
||||||
},
|
},
|
||||||
// yes, really source maps
|
// yes, really source maps
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
plugins: getDefaultNodePlugins(extConfig.context),
|
plugins: nodePlugins(extConfig.context),
|
||||||
};
|
};
|
||||||
|
|
||||||
return merge(defaultConfig, extConfig);
|
return merge(defaultConfig, extConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultNodePlugins(context) {
|
function nodePlugins(context) {
|
||||||
// Need to find the top-most `package.json` file
|
// Need to find the top-most `package.json` file
|
||||||
const folderName = path.relative(__dirname, context).split(/[\\\/]/)[0];
|
const folderName = path.relative(__dirname, context).split(/[\\\/]/)[0];
|
||||||
const pkgPath = path.join(__dirname, folderName, 'package.json');
|
const pkgPath = path.join(__dirname, folderName, 'package.json');
|
||||||
|
@ -136,14 +136,13 @@ function withBrowserDefaults(/**@type WebpackConfig*/extConfig) {
|
||||||
},
|
},
|
||||||
// yes, really source maps
|
// yes, really source maps
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
plugins: getDefaultBrowserPlugins()
|
plugins: browserPlugins
|
||||||
};
|
};
|
||||||
|
|
||||||
return merge(defaultConfig, extConfig);
|
return merge(defaultConfig, extConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultBrowserPlugins() {
|
const browserPlugins = [
|
||||||
return [
|
|
||||||
new CopyWebpackPlugin({
|
new CopyWebpackPlugin({
|
||||||
patterns: [
|
patterns: [
|
||||||
{ from: 'src', to: '.', globOptions: { ignore: ['**/test/**', '**/*.ts'] }, noErrorOnMissing: true }
|
{ from: 'src', to: '.', globOptions: { ignore: ['**/test/**', '**/*.ts'] }, noErrorOnMissing: true }
|
||||||
|
@ -154,13 +153,13 @@ function getDefaultBrowserPlugins() {
|
||||||
'process.env.BROWSER_ENV': JSON.stringify('true')
|
'process.env.BROWSER_ENV': JSON.stringify('true')
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = withNodeDefaults;
|
module.exports = withNodeDefaults;
|
||||||
module.exports.node = withNodeDefaults;
|
module.exports.node = withNodeDefaults;
|
||||||
module.exports.browser = withBrowserDefaults;
|
module.exports.browser = withBrowserDefaults;
|
||||||
module.exports.getNodePlugins = getDefaultNodePlugins;
|
module.exports.nodePlugins = nodePlugins;
|
||||||
module.exports.getBrowserPlugins = getDefaultBrowserPlugins;
|
module.exports.browserPlugins = browserPlugins;
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
const CopyPlugin = require('copy-webpack-plugin');
|
const CopyPlugin = require('copy-webpack-plugin');
|
||||||
const Terser = require('terser');
|
const Terser = require('terser');
|
||||||
|
|
||||||
const defaultConnfig = require('../shared.webpack.config');
|
const defaultConfig = require('../shared.webpack.config');
|
||||||
const withBrowserDefaults = defaultConnfig.browser;
|
const withBrowserDefaults = defaultConfig.browser;
|
||||||
const getBrowserPlugins = defaultConnfig.getBrowserPlugins;
|
const browserPlugins = defaultConfig.browserPlugins;
|
||||||
|
|
||||||
const languages = [
|
const languages = [
|
||||||
'zh-tw',
|
'zh-tw',
|
||||||
|
@ -34,13 +34,8 @@ module.exports = withBrowserDefaults({
|
||||||
entry: {
|
entry: {
|
||||||
extension: './src/extension.browser.ts',
|
extension: './src/extension.browser.ts',
|
||||||
},
|
},
|
||||||
resolve: {
|
|
||||||
fallback: {
|
|
||||||
os: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
plugins: [
|
plugins: [
|
||||||
...getBrowserPlugins(), // add plugins, don't replace inherited
|
...browserPlugins, // add plugins, don't replace inherited
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
new CopyPlugin({
|
new CopyPlugin({
|
||||||
|
|
Loading…
Reference in a new issue