Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: minify css #3862

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
node_modules/
dist/
src/public/app-dist/
src/public/stylesheets-dist/
npm-debug.log
yarn-error.log
*.db
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ RUN set -x \
&& npm prune --omit=dev \
&& cp src/public/app/share.js src/public/app-dist/. \
&& cp -r src/public/app/doc_notes src/public/app-dist/. \
&& rm -rf src/public/app
&& rm -rf src/public/app \
&& rm -rf src/public/stylesheets


# Some setup tools need to be kept
RUN apk add --no-cache su-exec shadow
Expand Down
1 change: 1 addition & 0 deletions bin/copy-trilium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ cp $DIR/src/public/app/share.js $DIR/src/public/app-dist/
cp -r $DIR/src/public/app/doc_notes $DIR/src/public/app-dist/

rm -rf $DIR/src/public/app
rm -rf $DIR/src/public/stylesheets
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"build-backend-docs": "rm -rf ./docs/backend_api && ./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/backend_api src/becca/entities/*.js src/services/backend_script_api.js src/services/sql.js",
"build-frontend-docs": "rm -rf ./docs/frontend_api && ./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/app/entities/*.js src/public/app/services/frontend_script_api.js src/public/app/widgets/right_panel_widget.js",
"build-docs": "npm run build-backend-docs && npm run build-frontend-docs",
"webpack": "webpack -c webpack.config.js",
"webpack": "webpack -c webpack.config.js && npm run postcss",
"postcss": "postcss src/public/stylesheets --dir src/public/stylesheets-dist -u cssnano --no-map",
"test-jasmine": "jasmine",
"test-es6": "node -r esm spec-es6/attribute_parser.spec.js ",
"test": "npm run test-jasmine && npm run test-es6",
Expand Down Expand Up @@ -97,6 +98,7 @@
},
"devDependencies": {
"cross-env": "7.0.3",
"cssnano": "^6.0.0",
"electron": "16.2.8",
"electron-builder": "23.6.0",
"electron-packager": "17.1.1",
Expand All @@ -116,6 +118,8 @@
"lorem-ipsum": "2.0.8",
"prettier": "2.8.7",
"nodemon": "^2.0.22",
"postcss": "^8.4.23",
"postcss-cli": "^10.1.0",
"rcedit": "3.0.1",
"webpack": "5.78.0",
"webpack-cli": "5.0.1"
Expand All @@ -126,4 +130,4 @@
"lint-staged": {
"*.js": "eslint --cache --fix"
}
}
}
9 changes: 6 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const dataDir = require('./services/data_dir');
const utils = require('./services/utils');
const assetPath = require('./services/asset_path');
const env = require('./services/env');
const isDev = env.isDev();
require('./services/handlers');
require('./becca/becca_loader');

Expand All @@ -32,7 +33,7 @@ app.use(helmet({
}));

const persistentCacheStatic = (root, options) => {
if (!env.isDev()) {
if (!isDev) {
options = {
maxAge: '1y',
...options
Expand All @@ -51,8 +52,10 @@ app.use(`/${assetPath}/app`, persistentCacheStatic(path.join(__dirname, 'public/
app.use(`/${assetPath}/app-dist`, persistentCacheStatic(path.join(__dirname, 'public/app-dist')));
app.use(`/${assetPath}/fonts`, persistentCacheStatic(path.join(__dirname, 'public/fonts')));
app.use(`/assets/vX/fonts`, express.static(path.join(__dirname, 'public/fonts')));
app.use(`/${assetPath}/stylesheets`, persistentCacheStatic(path.join(__dirname, 'public/stylesheets')));
app.use(`/assets/vX/stylesheets`, express.static(path.join(__dirname, 'public/stylesheets')));

app.use(`/${assetPath}/stylesheets`, persistentCacheStatic(path.join(__dirname, `public/stylesheets${isDev ? '' : '-dist'}`)));
app.use(`/assets/vX/stylesheets`, express.static(path.join(__dirname, `public/stylesheets${isDev ? '' : '-dist'}`)));

app.use(`/${assetPath}/libraries`, persistentCacheStatic(path.join(__dirname, '..', 'libraries')));
app.use(`/assets/vX/libraries`, express.static(path.join(__dirname, '..', 'libraries')));
// excalidraw-view mode in shared notes
Expand Down