Skip to content

bundle the extension with webpack #416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules
*.vsix
.DS_Store
coverage
dist

# Fortran files
*.o
Expand Down
3 changes: 2 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.vscode/**
.vscode-test/**
out/test/**
out
node_modules
test/**
src/**
**/*.map
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"onLanguage:FortranFreeForm",
"onLanguage:FortranFixedForm"
],
"main": "./out/src/extension",
"main": "./dist/src/extension",
"extensionDependencies": [
"ms-vscode.cpptools"
],
Expand Down Expand Up @@ -239,7 +239,7 @@
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
"vscode:prepublish": "webpack --mode production",
"compile": "tsc -p tsconfig.prod.json",
"compile-dev": "tsc -p tsconfig.json",
"watch": "tsc -watch -p tsconfig.prod.json",
Expand All @@ -265,6 +265,7 @@
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.10.2",
"@vscode/test-electron": "^2.1.2",
"copy-webpack-plugin": "^10.2.4",
"eslint": "^8.8.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsdoc": "^37.8.0",
Expand All @@ -273,8 +274,11 @@
"lint-staged": "^12.3.2",
"mocha": "^9.2.0",
"prettier": "^2.5.1",
"ts-loader": "^9.2.8",
"typescript": "^4.5.5",
"vscode-tmgrammar-test": "^0.0.11"
"vscode-tmgrammar-test": "^0.0.11",
"webpack": "^5.72.0",
"webpack-cli": "^4.9.2"
},
"lint-staged": {
"*.ts": [
Expand Down
58 changes: 58 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//@ts-check

'use strict';

const path = require('path');
const CopyPlugin = require("copy-webpack-plugin");

/**@type {import('webpack').Configuration}*/
const config = {
// vscode extensions run in a Node.js-context -> https://webpack.js.org/configuration/node/
target: 'node',

plugins: [
new CopyPlugin({
patterns: [
{ from: "src/docs", to: "../docs" },
],
}),
],

// the entry point of this extension -> https://webpack.js.org/configuration/entry-context/
entry: './src/extension.ts',
output: {
// the bundle is stored in the 'dist' folder (check package.json) -> https://webpack.js.org/configuration/output/
path: path.resolve(__dirname, 'dist', 'src'),
filename: 'extension.js',
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '../[resource-path]',
clean: true
},
// devtool: 'source-map',
externals: {
// 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/
vscode: 'commonjs vscode'
},
resolve: {
// support reading TypeScript and JavaScript files -> https://github.com/TypeStrong/ts-loader
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: {
configFile: "tsconfig.prod.json"
}
}
]
}
]
},
};
module.exports = config;