Add webpack compression plugin.
This commit is contained in:
parent
fe19a98829
commit
26f8adcd4e
|
@ -1128,6 +1128,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"compression-webpack-plugin": {
|
||||||
|
"version": "7.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/compression-webpack-plugin/-/compression-webpack-plugin-7.1.2.tgz",
|
||||||
|
"integrity": "sha512-9DKNW6ILLjx+bNBoviHDgLx6swBhWWH9ApClC9sTH2NoFfQM47BapQfovCm9zjD9v1uZwInF5a925FB9ErGQeQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"schema-utils": "^3.0.0",
|
||||||
|
"serialize-javascript": "^5.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/google-protobuf": "^3.7.4",
|
"@types/google-protobuf": "^3.7.4",
|
||||||
"clean-webpack-plugin": "^3.0.0",
|
"clean-webpack-plugin": "^3.0.0",
|
||||||
|
"compression-webpack-plugin": "^7.1.2",
|
||||||
"html-webpack-plugin": "^4.5.0",
|
"html-webpack-plugin": "^4.5.0",
|
||||||
"ts-loader": "^8.0.13",
|
"ts-loader": "^8.0.13",
|
||||||
"ts-protoc-gen": "^0.14.0",
|
"ts-protoc-gen": "^0.14.0",
|
||||||
|
|
|
@ -1,67 +1,69 @@
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||||
|
const CompressionPlugin = require("compression-webpack-plugin");
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const root = path.resolve(__dirname, '.');
|
const root = path.resolve(__dirname, '.');
|
||||||
|
|
||||||
function packPage(page, chunks) {
|
function packPage(page, chunks) {
|
||||||
if (!chunks) chunks = [];
|
if (!chunks) chunks = [];
|
||||||
return new HtmlWebpackPlugin({
|
return new HtmlWebpackPlugin({
|
||||||
template: `${root}/src/frontend/templates/${page}`,
|
template: `${root}/src/frontend/templates/${page}`,
|
||||||
filename: `${root}/generated/templates/${page}`,
|
filename: `${root}/generated/templates/${page}`,
|
||||||
publicPath: '/',
|
publicPath: '/',
|
||||||
scriptLoading: 'defer',
|
scriptLoading: 'defer',
|
||||||
chunks: chunks,
|
chunks: chunks,
|
||||||
inject: false,
|
inject: false,
|
||||||
minify: false
|
minify: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: {
|
entry: {
|
||||||
edit_character: "./src/frontend/scripts/characters/edit.ts",
|
edit_character: "./src/frontend/scripts/characters/edit.ts",
|
||||||
},
|
|
||||||
optimization: {
|
|
||||||
runtimeChunk: "single",
|
|
||||||
splitChunks: {
|
|
||||||
chunks: 'all',
|
|
||||||
},
|
},
|
||||||
},
|
optimization: {
|
||||||
mode: "development",
|
runtimeChunk: "single",
|
||||||
output: {
|
splitChunks: {
|
||||||
path: `${root}/generated`,
|
chunks: 'all',
|
||||||
filename: 'scripts/dist/[name].bundle.js'
|
},
|
||||||
},
|
},
|
||||||
devtool: 'inline-source-map',
|
mode: "development",
|
||||||
module: {
|
output: {
|
||||||
rules: [
|
path: `${root}/generated`,
|
||||||
{
|
filename: 'scripts/dist/[name].bundle.js'
|
||||||
test: /\.ts$/,
|
},
|
||||||
include: /src|_proto/,
|
devtool: 'inline-source-map',
|
||||||
exclude: /node_modules/,
|
module: {
|
||||||
loader: "ts-loader"
|
rules: [
|
||||||
}
|
{
|
||||||
|
test: /\.ts$/,
|
||||||
|
include: /src|_proto/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
loader: "ts-loader"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: [".ts", ".js"]
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new CleanWebpackPlugin({
|
||||||
|
cleanOnceBeforeBuildPatterns: ['!templates/**/*'],
|
||||||
|
cleanAfterEveryBuildPatterns: ['!templates/**/*'],
|
||||||
|
dry: false
|
||||||
|
}),
|
||||||
|
new CompressionPlugin(),
|
||||||
|
packPage('login.html.tera'),
|
||||||
|
packPage('base.html.tera'),
|
||||||
|
packPage('error.html.tera'),
|
||||||
|
packPage('index.html.tera'),
|
||||||
|
packPage('registration.html.tera'),
|
||||||
|
packPage('characters/edit_character.html.tera', ['edit_character']),
|
||||||
|
packPage('characters/edit_character_macros.html.tera'),
|
||||||
|
packPage('characters/new_character.html.tera'),
|
||||||
|
packPage('characters/view_character.html.tera'),
|
||||||
|
packPage('characters/view_character_macros.html.tera'),
|
||||||
]
|
]
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: [".ts", ".js"]
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new CleanWebpackPlugin({
|
|
||||||
cleanOnceBeforeBuildPatterns: ['!templates/**/*'],
|
|
||||||
cleanAfterEveryBuildPatterns: ['!templates/**/*'],
|
|
||||||
dry: false
|
|
||||||
}),
|
|
||||||
packPage('login.html.tera'),
|
|
||||||
packPage('base.html.tera'),
|
|
||||||
packPage('error.html.tera'),
|
|
||||||
packPage('index.html.tera'),
|
|
||||||
packPage('registration.html.tera'),
|
|
||||||
packPage('characters/edit_character.html.tera', ['edit_character']),
|
|
||||||
packPage('characters/edit_character_macros.html.tera'),
|
|
||||||
packPage('characters/new_character.html.tera'),
|
|
||||||
packPage('characters/view_character.html.tera'),
|
|
||||||
packPage('characters/view_character_macros.html.tera'),
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue