mirror of
https://github.com/flarum/framework.git
synced 2024-11-22 14:41:39 +08:00
Add option to build with Webpack Bundle Analyzer (#2708)
* Add option to build with webpack bundle analyzer * Bump npm to v7 as recommended in actions/setup-node#213 * Workaround for npm/cli#558 * Add missing dep
This commit is contained in:
parent
b1f166d82a
commit
e52b769ceb
6
.github/workflows/pr_size_change.yml
vendored
6
.github/workflows/pr_size_change.yml
vendored
|
@ -25,8 +25,12 @@ jobs:
|
||||||
with:
|
with:
|
||||||
node-version: "14"
|
node-version: "14"
|
||||||
|
|
||||||
|
- name: Use npm v7
|
||||||
|
run: sudo npm install -g npm@7.x.x
|
||||||
|
|
||||||
- name: Install JS dependencies
|
- name: Install JS dependencies
|
||||||
run: npm ci
|
# We need to use `npm install` here. If we don't, the workflow will fail.
|
||||||
|
run: npm install
|
||||||
working-directory: ./js
|
working-directory: ./js
|
||||||
|
|
||||||
- name: Build production assets
|
- name: Build production assets
|
||||||
|
|
1029
js/package-lock.json
generated
1029
js/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -23,16 +23,19 @@
|
||||||
"@types/punycode": "^2.1.0",
|
"@types/punycode": "^2.1.0",
|
||||||
"@types/textarea-caret": "^3.0.0",
|
"@types/textarea-caret": "^3.0.0",
|
||||||
"bundlewatch": "^0.3.2",
|
"bundlewatch": "^0.3.2",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
"flarum-webpack-config": "0.1.0-beta.10",
|
"flarum-webpack-config": "0.1.0-beta.10",
|
||||||
"husky": "^4.3.8",
|
"husky": "^4.3.8",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "^2.2.1",
|
||||||
"webpack": "^4.46.0",
|
"webpack": "^4.46.0",
|
||||||
|
"webpack-bundle-analyzer": "^4.4.0",
|
||||||
"webpack-cli": "^3.3.12",
|
"webpack-cli": "^3.3.12",
|
||||||
"webpack-merge": "^4.2.2"
|
"webpack-merge": "^4.2.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "webpack --mode development --watch",
|
"dev": "webpack --mode development --watch",
|
||||||
"build": "webpack --mode production",
|
"build": "webpack --mode production",
|
||||||
|
"analyze": "cross-env ANALYZER=true npm run build",
|
||||||
"format": "prettier --write src",
|
"format": "prettier --write src",
|
||||||
"format-check": "prettier --check src"
|
"format-check": "prettier --check src"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
const config = require('flarum-webpack-config');
|
const config = require('flarum-webpack-config');
|
||||||
|
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||||
const merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
|
|
||||||
|
const useBundleAnalyzer = process.env.ANALYZER === 'true';
|
||||||
|
|
||||||
|
const plugins = [];
|
||||||
|
|
||||||
|
if (useBundleAnalyzer) {
|
||||||
|
plugins.push(new BundleAnalyzerPlugin());
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = merge(config(), {
|
module.exports = merge(config(), {
|
||||||
output: {
|
output: {
|
||||||
library: 'flarum.core',
|
library: 'flarum.core',
|
||||||
|
@ -10,6 +19,8 @@ module.exports = merge(config(), {
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.ts', '.tsx', '.js', '.json'],
|
extensions: ['.ts', '.tsx', '.js', '.json'],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
plugins,
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports['module'].rules[0].test = /\.(tsx?|js)$/;
|
module.exports['module'].rules[0].test = /\.(tsx?|js)$/;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user