|
6 | 6 | 'use strict'; |
7 | 7 |
|
8 | 8 | const path = require('path'); |
| 9 | +const CopyWebpackPlugin = require('copy-webpack-plugin'); |
| 10 | +const merge = require('merge-options'); |
9 | 11 |
|
10 | | -/** |
11 | | - * Function that must be invoked with __dirname and that |
12 | | - * returns a good default configuation for extensions that |
13 | | - * want to do webpack |
14 | | - */ |
15 | | -module.exports = function (extensionDir) { |
16 | | - return { |
17 | | - context: extensionDir, |
| 12 | +module.exports = function withDefaults(extConfig) { |
| 13 | + let defaultConfig = { |
18 | 14 | mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production') |
19 | 15 | target: 'node', // extensions run in a node context |
20 | 16 | resolve: { |
@@ -43,14 +39,75 @@ module.exports = function (extensionDir) { |
43 | 39 | }] |
44 | 40 | }] |
45 | 41 | }, |
| 42 | + plugins: [ |
| 43 | + new CopyWebpackPlugin([{ from: './out/nls.*.json', to: '[name].json' }]) // copy nls files |
| 44 | + ], |
| 45 | + externals: { |
| 46 | + 'vscode': 'commonjs vscode', // ignored because it doesn't exist |
| 47 | + }, |
46 | 48 | output: { |
47 | 49 | // all output goes into `dist`. |
48 | 50 | // packaging depends on that and this must always be like it |
49 | 51 | filename: '[name].js', |
50 | | - path: path.join(extensionDir, 'dist'), |
| 52 | + path: path.join(extConfig.context, 'dist'), |
51 | 53 | libraryTarget: "commonjs", |
52 | 54 | }, |
53 | 55 | // yes, really source maps |
54 | 56 | devtool: 'source-map' |
55 | | - }; |
56 | | -}; |
| 57 | + } |
| 58 | + |
| 59 | + return merge(defaultConfig, extConfig); |
| 60 | +} |
| 61 | + |
| 62 | +// /** |
| 63 | +// * Function that must be invoked with __dirname and that |
| 64 | +// * returns a good default configuation for extensions that |
| 65 | +// * want to do webpack |
| 66 | +// */ |
| 67 | +// module.exports = function (extensionDir) { |
| 68 | +// return { |
| 69 | +// context: extensionDir, |
| 70 | +// mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production') |
| 71 | +// target: 'node', // extensions run in a node context |
| 72 | +// resolve: { |
| 73 | +// mainFields: ['main'], // prefer the main-entry of package.json files |
| 74 | +// extensions: ['.ts', '.js'] // support ts-files and js-files |
| 75 | +// }, |
| 76 | +// module: { |
| 77 | +// rules: [{ |
| 78 | +// test: /\.ts$/, |
| 79 | +// exclude: /node_modules/, |
| 80 | +// use: [{ |
| 81 | +// // vscode-nls-dev loader: |
| 82 | +// // * rewrite nls-calls |
| 83 | +// loader: 'vscode-nls-dev/lib/webpack-loader' |
| 84 | +// }, { |
| 85 | +// // configure TypeScript loader: |
| 86 | +// // * only transpile because we have a separate compilation pipeline |
| 87 | +// // * enable sources maps for end-to-end source maps |
| 88 | +// loader: 'ts-loader', |
| 89 | +// options: { |
| 90 | +// transpileOnly: true, |
| 91 | +// compilerOptions: { |
| 92 | +// "sourceMap": true, |
| 93 | +// } |
| 94 | +// } |
| 95 | +// }] |
| 96 | +// }] |
| 97 | +// }, |
| 98 | +// plugins: [ |
| 99 | +// new CopyWebpackPlugin([ |
| 100 | +// { from: './out/nls.*.json', to: '[name].json' } |
| 101 | +// ]) |
| 102 | +// ], |
| 103 | +// output: { |
| 104 | +// // all output goes into `dist`. |
| 105 | +// // packaging depends on that and this must always be like it |
| 106 | +// filename: '[name].js', |
| 107 | +// path: path.join(extensionDir, 'dist'), |
| 108 | +// libraryTarget: "commonjs", |
| 109 | +// }, |
| 110 | +// // yes, really source maps |
| 111 | +// devtool: 'source-map' |
| 112 | +// }; |
| 113 | +// }; |
0 commit comments