Skip to content

Commit

Permalink
Add bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin Spencer-Harper committed Oct 8, 2020
1 parent e23dc86 commit 46ad518
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

# production
/build
/bundled

# misc
.DS_Store
Expand Down
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"onCommand:vscode-refactor-by-js.start",
"onWebviewPanel:vscode-refactor-by-js"
],
"main": "./build/ext-src/extension.js",
"main": "./bundled/extension.js",
"contributes": {
"commands": [
{
Expand Down Expand Up @@ -55,9 +55,9 @@
"terser": "3.14.1"
},
"scripts": {
"vscode:prepublish": "./scripts/build-non-split.js && tsc -p tsconfig.extension.json",
"vscode:prepublish": "./scripts/build-non-split.js && webpack --mode none",
"start": "react-scripts start",
"build": "./scripts/build-non-split.js && tsc -p tsconfig.extension.json",
"build": "./scripts/build-non-split.js && webpack --mode none",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"postinstall": "node ./node_modules/vscode/bin/install"
Expand All @@ -73,7 +73,11 @@
"vscode": "^1.0.0",
"react-scripts": "^2.1.3",
"rewire": "^4.0.1",
"typescript": "^4.0.2"
"typescript": "^4.0.2",
"ts-loader": "^5.3.3",
"webpack": "4.28.3",
"webpack-cli": "^3.3.0"

},
"browserslist": [
">0.2%",
Expand Down
41 changes: 41 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//@ts-check

'use strict';

const path = require('path');

/**@type {import('webpack').Configuration}*/
const config = {
target: 'node',

entry: './ext-src/extension.ts',
output: {
path: path.resolve(__dirname, 'bundled'),
filename: 'extension.js',
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '../[resource-path]'
},
devtool: 'source-map',
externals: {
vscode: 'commonjs vscode', // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
typescript: 'commonjs typescript'
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: { configFile: "tsconfig.extension.json" }
}
]
}
]
}
};
module.exports = config;
Loading

0 comments on commit 46ad518

Please sign in to comment.