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": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
"devDependencies": {
|
||||
"@types/google-protobuf": "^3.7.4",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"compression-webpack-plugin": "^7.1.2",
|
||||
"html-webpack-plugin": "^4.5.0",
|
||||
"ts-loader": "^8.0.13",
|
||||
"ts-protoc-gen": "^0.14.0",
|
||||
|
|
|
@ -1,67 +1,69 @@
|
|||
const webpack = require('webpack');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const CompressionPlugin = require("compression-webpack-plugin");
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const path = require('path');
|
||||
|
||||
const root = path.resolve(__dirname, '.');
|
||||
|
||||
function packPage(page, chunks) {
|
||||
if (!chunks) chunks = [];
|
||||
return new HtmlWebpackPlugin({
|
||||
template: `${root}/src/frontend/templates/${page}`,
|
||||
filename: `${root}/generated/templates/${page}`,
|
||||
publicPath: '/',
|
||||
scriptLoading: 'defer',
|
||||
chunks: chunks,
|
||||
inject: false,
|
||||
minify: false
|
||||
});
|
||||
if (!chunks) chunks = [];
|
||||
return new HtmlWebpackPlugin({
|
||||
template: `${root}/src/frontend/templates/${page}`,
|
||||
filename: `${root}/generated/templates/${page}`,
|
||||
publicPath: '/',
|
||||
scriptLoading: 'defer',
|
||||
chunks: chunks,
|
||||
inject: false,
|
||||
minify: false
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
edit_character: "./src/frontend/scripts/characters/edit.ts",
|
||||
},
|
||||
optimization: {
|
||||
runtimeChunk: "single",
|
||||
splitChunks: {
|
||||
chunks: 'all',
|
||||
entry: {
|
||||
edit_character: "./src/frontend/scripts/characters/edit.ts",
|
||||
},
|
||||
},
|
||||
mode: "development",
|
||||
output: {
|
||||
path: `${root}/generated`,
|
||||
filename: 'scripts/dist/[name].bundle.js'
|
||||
},
|
||||
devtool: 'inline-source-map',
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts$/,
|
||||
include: /src|_proto/,
|
||||
exclude: /node_modules/,
|
||||
loader: "ts-loader"
|
||||
}
|
||||
optimization: {
|
||||
runtimeChunk: "single",
|
||||
splitChunks: {
|
||||
chunks: 'all',
|
||||
},
|
||||
},
|
||||
mode: "development",
|
||||
output: {
|
||||
path: `${root}/generated`,
|
||||
filename: 'scripts/dist/[name].bundle.js'
|
||||
},
|
||||
devtool: 'inline-source-map',
|
||||
module: {
|
||||
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