Add minification
This commit is contained in:
parent
b3da27e73b
commit
d34f25295c
14 changed files with 142 additions and 94 deletions
|
|
@ -13,16 +13,16 @@
|
|||
"keywords": [],
|
||||
"author": "András Schmelczer <andras@schmelczer.dev> (https://schmelczer.dev/)",
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.4",
|
||||
"concurrently": "^5.3.0",
|
||||
"webpack": "^4.43.0",
|
||||
"webpack-cli": "^3.3.11",
|
||||
"terser-webpack-plugin": "^2.3.5",
|
||||
"webpack-dev-server": "^3.10.3",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"concurrently": "^5.3.0",
|
||||
"esbuild-loader": "^2.4.0",
|
||||
"nodemon": "^2.0.4",
|
||||
"raw-loader": "^4.0.1",
|
||||
"resolve-url-loader": "^3.1.1",
|
||||
"ts-loader": "^8.0.1"
|
||||
"terser-webpack-plugin": "^2.3.5",
|
||||
"webpack": "^4.43.0",
|
||||
"webpack-cli": "^3.3.11",
|
||||
"webpack-dev-server": "^3.10.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"cors": "^2.8.5",
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist/",
|
||||
"sourceMap": true,
|
||||
"noImplicitAny": false,
|
||||
"target": "es5",
|
||||
"downlevelIteration": true,
|
||||
"allowJs": true,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "node",
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,15 @@
|
|||
const path = require('path');
|
||||
const TerserJSPlugin = require('terser-webpack-plugin');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const nodeExternals = require('webpack-node-externals');
|
||||
const { ESBuildPlugin } = require('esbuild-loader');
|
||||
const TerserJSPlugin = require('terser-webpack-plugin');
|
||||
|
||||
const PATHS = {
|
||||
entryPoint: path.resolve(__dirname, 'src/main.ts'),
|
||||
bundles: path.resolve(__dirname, 'dist'),
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
module.exports = (env, argv) => ({
|
||||
entry: {
|
||||
main: [PATHS.entryPoint],
|
||||
},
|
||||
|
|
@ -21,21 +23,29 @@ module.exports = {
|
|||
filename: '[name].js',
|
||||
path: PATHS.bundles,
|
||||
},
|
||||
devtool: 'source-map',
|
||||
devtool: argv.mode === 'development' ? 'source-map' : false,
|
||||
watchOptions: {
|
||||
poll: true
|
||||
},
|
||||
optimization: {
|
||||
minimize: true,
|
||||
usedExports: true,
|
||||
minimize: argv.mode !== 'development',
|
||||
minimizer: [
|
||||
new TerserJSPlugin({
|
||||
sourceMap: true,
|
||||
cache: true,
|
||||
test: /\.ts$/,
|
||||
sourceMap: false,
|
||||
test: /\.js$/,
|
||||
terserOptions: {
|
||||
keep_classnames: true,
|
||||
}
|
||||
}),
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new ESBuildPlugin(),
|
||||
new CleanWebpackPlugin({
|
||||
protectWebpackAssets: false,
|
||||
cleanAfterEveryBuildPatterns: [],
|
||||
}),
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
|
|
@ -50,14 +60,15 @@ module.exports = {
|
|||
},
|
||||
{
|
||||
test: /\.ts$/,
|
||||
use: {
|
||||
loader: 'ts-loader',
|
||||
},
|
||||
exclude: /node_modules/,
|
||||
loader: 'esbuild-loader',
|
||||
options: {
|
||||
loader: 'ts',
|
||||
target: 'es2015',
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js'],
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue