mirror of
https://github.com/mue/mue.git
synced 2026-06-08 14:10:42 +02:00
build: optimise production builds, automate creating zip files
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,6 +2,7 @@
|
||||
node_modules/
|
||||
.vscode/
|
||||
build/
|
||||
dist/
|
||||
|
||||
# Files
|
||||
package-lock.json
|
||||
|
||||
@@ -48,13 +48,15 @@
|
||||
"webpack": "^5.39.1",
|
||||
"webpack-cli": "^4.7.2",
|
||||
"webpack-dev-server": "^3.11.2",
|
||||
"webpack-merge": "^5.8.0"
|
||||
"webpack-merge": "^5.8.0",
|
||||
"zip-file-webpack-plugin": "^1.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "webpack serve --config webpack.dev.js",
|
||||
"build": "webpack --config webpack.prod.js",
|
||||
"chrome": "cp manifest/chrome.json build/manifest.json",
|
||||
"firefox": "cp manifest/firefox.json build/manifest.json"
|
||||
"build:chrome": "webpack --config webpack.prod.js --env=type=chrome",
|
||||
"build:firefox": "webpack --config webpack.prod.js --env=type=firefox",
|
||||
"postinstall": "node -e \"if (require('fs').existsSync('node_modules/.cache/webpack')) require('fs').rmSync('node_modules/.cache/webpack', { recursive: true })\""
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
|
||||
@@ -3,8 +3,12 @@ const common = require('./webpack.common.js');
|
||||
const path = require('path');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const CopyPlugin = require('copy-webpack-plugin');
|
||||
const ZipFilePlugin = require('zip-file-webpack-plugin');
|
||||
|
||||
module.exports = merge(common, {
|
||||
module.exports = (env) => {
|
||||
const type = env.type || 'web';
|
||||
|
||||
return merge(common, {
|
||||
mode: 'production',
|
||||
output: {
|
||||
path: path.resolve(__dirname, './build'),
|
||||
@@ -12,6 +16,9 @@ module.exports = merge(common, {
|
||||
chunkFilename: '[id].[chunkhash].chunk.js',
|
||||
clean: true
|
||||
},
|
||||
cache: {
|
||||
type: 'filesystem'
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.resolve(__dirname, './public/index.html')
|
||||
@@ -24,8 +31,17 @@ module.exports = merge(common, {
|
||||
{
|
||||
from: 'public/offline-images',
|
||||
to: 'offline-images'
|
||||
},
|
||||
{
|
||||
from: `manifest/${type}.json`,
|
||||
to: 'manifest.json'
|
||||
}
|
||||
]
|
||||
}),
|
||||
new ZipFilePlugin({
|
||||
path: '../dist/',
|
||||
filename: `${type}.zip`
|
||||
})
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user