• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

IlyaAI/wro4j-gradle-plugin: Gradle Wro4J Plugin

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

IlyaAI/wro4j-gradle-plugin

开源软件地址(OpenSource Url):

https://github.com/IlyaAI/wro4j-gradle-plugin

开源编程语言(OpenSource Language):

Groovy 58.6%

开源软件介绍(OpenSource Introduction):

Wro4J Gradle Plugin

Provides build-time solution for wro4j with Gradle.

Latest release: 1.8.0.Beta4

Getting Started

You could find complete example here

Step 1. Layout your web sources

Put your web sources (html, js, css, less, etc) in the following folders:

src/
  main/
    webResources/
      js/
        *.js
      themes/
        default/
          images/
            *.png; *.gif; ...
          *.css; *.less; ...
      static/
        index.html; ...

Plugin treats all paths against $projectDir/src/main/webResources. Files from static folder will be copied to output as is by default but for js and css it is necessary to provide bundle configuration (see step 4).

Step 2. Apply plugin

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'ro.isdc.wro4j.gradle:wro4j-gradle-plugin:1.8.0.Beta4'
    }
}
apply plugin: 'java'
apply plugin: 'wro4j'

Wro4J plugin requires Java plugin to be applied first.

Step 3. Add webjar dependencies

dependencies {
    webjars 'org.webjars:jquery:2.1.4'
    webjars 'org.webjars:bootstrap:3.3.4'
}

Step 4. Define bundles

webResources {
    bundle ('core') {
        js 'js/**/*.js'
        preProcessor 'jsMin'
    }

    bundle ('libs') {
        js 'webjars/jquery/2.1.4/jquery.min.js'
    }

    bundle ('theme-default') {
        css 'webjars/bootstrap/3.3.4/less/bootstrap.less'
        css 'themes/default/main.css'

        cssOverrideImport 'variables.less', '../../../../themes/default/variables.less'
        preProcessor 'less4j'
        cssRewriteUrl()
    }

    assets {
        include 'themes/default/images/**'
    }
}

You could reference webjar's content just using webjars/ prefix, e.g. webjars/bootstrap/3.3.4/less/bootstrap.less.

Step 5. Build

gradlew build

When build finished you will get a jar with the following resources:

static/
  themes/
    default/
      images/
        *.png; *.gif; ...
    core.js
    libs.js
    theme-default.css
    index.html; ...

FAQ

How should I use Bootstrap's glyph fonts?

Way A. Spring.Boot includes /webjars/* handler enabled by default, so use webjarsRuntime in dependencies section instead of webjars. In this case bootstrap.jar is added to your runtime libs and /webjars handler will be able to locate and return glyph fonts from bootstrap.jar.

Way B. If you do not use /webjars/* handler then you should copy fonts to you static resources and reference Bootstrap via webjars:

webResources {     
    assets {
       include "webjars/bootstrap/$versionBootstrap/fonts/**"
    }
}
dependencies {
    webjars ("org.webjars:bootstrap:$versionBootstrap")
}

Way C. It is also possible to use fonts from your static resources with enabled /webjars/* handler.

webResources {     
    from ("$buildMainDir/webjars/bootstrap/$versionBootstrap/fonts") {
        include '**'
        into 'themes/default/fonts'
    }
}
dependencies {
    webjars ("org.webjars:bootstrap:$versionBootstrap")
}

And override @icon-font-path inside variables.less

@icon-font-path:          "../../../../themes/default/fonts/";



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap