chore(build): 使用webpack打包减小体积

This commit is contained in:
宁宁 2020-02-23 16:18:33 +08:00
parent b8e6d63f69
commit ca52070798
4 changed files with 2383 additions and 11 deletions

View File

@ -7,4 +7,5 @@ vsc-extension-quickstart.md
**/tsconfig.json
**/tslint.json
**/*.map
**/*.ts
**/*.ts
**/node_modules

View File

@ -8,7 +8,7 @@
"build:md": "node ./scripts/md.js",
"build": "npm run test:rules && npm version patch && node ./scripts/genCommond.js && vsce package && npm run build:md",
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"compile": "webpack --mode production",
"watch": "tsc -watch -p ./",
"pretest": "npm run compile",
"test": "node ./out/test/runTest.js",
@ -303,9 +303,12 @@
"@types/vscode": "^1.12.0",
"glob": "^7.1.4",
"mocha": "^6.1.4",
"ts-loader": "^6.2.1",
"tslint": "^5.12.1",
"typescript": "^3.3.1",
"vscode-test": "^1.0.2"
"vscode-test": "^1.0.2",
"webpack": "^4.41.6",
"webpack-cli": "^3.3.11"
},
"dependencies": {
"axios": "^0.19.2",

42
webpack.config.js Normal file
View File

@ -0,0 +1,42 @@
// @ts-check
'use strict';
const path = require('path');
/**@type {import('webpack').Configuration}*/
const config = {
target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
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, 'out'),
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
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader'
}
]
}
]
}
};
module.exports = config;

2342
yarn.lock

File diff suppressed because it is too large Load Diff