Skip to content

Commit

Permalink
add: Use webpack to bundle extension
Browse files Browse the repository at this point in the history
  • Loading branch information
duckdoom4 committed May 30, 2022
1 parent 41a4376 commit 5da2738
Show file tree
Hide file tree
Showing 19 changed files with 5,423 additions and 291 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
node_modules
out
dist
*.vsix
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "ms-vscode.vscode-js-profile-flame"]
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "ms-vscode.vscode-js-profile-flame", "amodio.tsl-problem-matcher"]
}
18 changes: 15 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,37 @@
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"name": "Launch Extension (Debug)",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"${workspaceFolder}/examples" // open examples directory
],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "npm: watch"
},
{
"name": "Launch Extension (Release)",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"${workspaceFolder}/examples" // open examples directory
],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "npm: watch-release"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}", "--extensionTestsPath=${workspaceFolder}/out/test"],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"preLaunchTask": "npm: watch"
"preLaunchTask": "npm: test-compile"
}
]
}
19 changes: 17 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,34 @@
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"problemMatcher": ["$ts-checker-webpack-watch", "$ts-checker-eslint-webpack-watch"],
"isBackground": true,
"presentation": {
"reveal": "never"
"reveal": "never",
"clear": true,
"close": true
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "npm",
"script": "watch-release",
"problemMatcher": ["$ts-checker-webpack-watch", "$ts-checker-eslint-webpack-watch"],
"isBackground": true,
"presentation": {
"reveal": "never",
"clear": true,
"close": true
},
"group": "build"
},
{
"type": "npm",
"script": "lint",
"group": "build",
"problemMatcher": ["$eslint-stylish"]
}
]
Expand Down
22 changes: 15 additions & 7 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
.github/**
.vscode/**
.vscode-test/**
examples/**
src
out
node_modules
out/test/**
out/**/*.map
**/*.ts
**/*.map

# Specific root files
.editorconfig
.eslintric.json
.gitattributes
.gitignore
CODE_OF_CONDUCT.md
Contributing.md
package-lock.json
tsconfig.json
vsc-extension-quickstart.md
tslint.json
!renpy.json
!renpyauto.json
browser.webpack.config.ts
webpack.config.ts
26 changes: 26 additions & 0 deletions browser.webpack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import NodePolyfillPlugin from "node-polyfill-webpack-plugin";
import { Configuration, DefinePlugin } from "webpack";
import { basePlugins, baseConfig } from "./webpack.config";

export const browserConfig: Configuration = {
target: "webworker", // extensions run in a webworker context
resolve: {
mainFields: ["browser", "module", "main"],
extensions: [".ts", ".js"], // support ts-files and js-files
},
performance: {
hints: false,
},
plugins: [
new NodePolyfillPlugin(),
new DefinePlugin({
"process.platform": JSON.stringify("web"),
"process.env": JSON.stringify({}),
"process.env.BROWSER_ENV": JSON.stringify("true"),
}),
...basePlugins,
],
...baseConfig,
};

export default browserConfig;
Loading

0 comments on commit 5da2738

Please sign in to comment.