Legacy Knowledge Base
公開されました Jun. 30, 2025

カスタマイズでCSSとJavascriptリソースを最小化する方法

Written By

Anushka Tiwari

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

問題

  • Liferayテーマビルダーを使用してCSSとJavascriptリソースの最小化を実行する方法。

環境

  • Liferay DXP 7.4

解像度

  • Gradleから gulpビルドテーマで

    基本的には、Gradleテーマのビルド・プロセスをgulpに置き換えることで、node.jsバージョンのビルド・プロセスと同一ではないにしても、非常に似たものにすることだ。

    1. ファイルシステムのどこかに空のフォルダを作る。
    2. この空のフォルダで、環境のセットアップとテーマの作成から yo liferay-themeのステップまで、すべての指示に従い、最初に作成したGradleベースのテーマと同じテーマ名とテーマベースを指定することを確認します。
    3. 生成されたテーマから以下のファイルをGradleベースのテーマにコピーする。
      • liferay-theme.json
      • package.json
      • package-lock.json
    4. Gradleベースのテーマのトップ・レベルに新しいファイルgulpfile.jsを作成する:
    'use strict';
    
    var gulp = require('gulp');
    var liferayThemeTasks = require('liferay-theme-tasks');
    
    liferayThemeTasks.registerTasks({
     gulp: gulp,
     pathDist: 'build/libs/',
     pathSrc: 'src/main/webapp/'
    });
    • Liferayテーマジェネレータをインストールするときに、gulp経由で直接ビルドします。 次に、gulp.jsファイルの先頭に以下の行を追加する:
    process.env.NODE_ENV = 'production';
    • ドキュメントのbuild.gradleの最後に以下を追加する:
      • NODE_ENV変数がproductionに設定されていることを確認し、gulp buildがCSSをminifyするようにする。
      • buildCSSタスクをgulp buildへの呼び出しに置き換える。
      • すでにgulp buildでwarを生成したので、warタスクのアクションをクリアする
    apply plugin: "com.liferay.node"
    tasks.getByPath('packageRunBuild').configure {
    environment "NODE_ENV", "production"
    }
    tasks.getByPath('buildCSS').configure {
    actions.clear()
    finalizedBy packageRunBuild
    }
    tasks.getByPath('war').configure {
    actions.clear()
    }
    • 通常通りブレードgwを展開する。

追加情報

Did this article resolve your issue ?

Legacy Knowledge Base