Skip to content

Commit

Permalink
use webpack to package extension
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasRentzCAU committed Jun 17, 2024
1 parent 255705c commit d4c05c3
Show file tree
Hide file tree
Showing 5 changed files with 934 additions and 62 deletions.
2 changes: 1 addition & 1 deletion extension/osgiviz/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*.jar
*.vsix
build
out
dist
lerna-debug.log
lib
node_modules
Expand Down
14 changes: 9 additions & 5 deletions extension/osgiviz/.vscodeignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
.vscode/**
.vscode-test/**
out/test/**

*.vsix
node_modules
out/**
src/**
.gitignore
.yarnrc
vsc-extension-quickstart.md
**/tsconfig.json
webpack.config.js
**/.eslintrc.json
**/*.map
**/webpack.config.js
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.ts

*.code-workspace
*.vsix
*.code-workspace
13 changes: 8 additions & 5 deletions extension/osgiviz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"workspaceContains:**/*.{osgiviz,model}",
"onLanguage:xml"
],
"main": "./out/extension.js",
"main": "./dist/extension.js",
"contributes": {
"menus": {
"editor/title": [
Expand Down Expand Up @@ -49,17 +49,20 @@
"redhat.vscode-xml"
],
"scripts": {
"vscode:prepublish": "yarn run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"vscode:prepublish": "yarn run build",
"build": "webpack --mode production",
"watch": "webpack --mode development --watch",
"package": "vsce package --yarn",
"distribute": "vsce publish --yarn && ovsx publish --yarn"
},
"devDependencies": {
"@types/vscode": "^1.89.1",
"@types/node": "^20.14.2",
"@vscode/vsce": "^2.27.0",
"ts-loader": "9.5.1",
"typescript": "^5.4.5",
"vsce": "^2.15.0",
"webpack": "5.92.0",
"webpack-cli": "5.1.4",
"ovsx": "^0.9.1"
},
"dependencies": {
Expand Down
52 changes: 52 additions & 0 deletions extension/osgiviz/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//@ts-check

'use strict';

const path = require('path');
const webpack = require('webpack');

/**@type {import('webpack').Configuration}*/
const config = {
target: "node", // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
mode: "none", // this leaves the source code as close as possible to the original (when packaging we set this to 'production')

entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
output: {
// the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
path: path.resolve(__dirname, 'dist'),
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/
},
resolve: {
// support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
mainFields: ['browser', 'module', 'main'], // look for `browser` entry point in imported node modules
extensions: ['.ts', '.js'],
alias: {
// provides alternate implementation for node module and source files
},
fallback: {
// Webpack 5 no longer polyfills Node.js core modules automatically.
// see https://webpack.js.org/configuration/resolve/#resolvefallback
// for the list of Node.js core module polyfills.
}
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader'
}
]
}
]
}
};
module.exports = config;
Loading

0 comments on commit d4c05c3

Please sign in to comment.