bertramdev / grails-asset-pipeline

Grails Asset Pipeline
Apache License 2.0
78 stars 64 forks source link

not including my html assets ? #336

Open walshe opened 8 years ago

walshe commented 8 years ago

Im using grails 3.1.3 which uses this plugin as far as I know.

For some reason my angular html templates are not getting processed by the plugin (however if i put a .js file in the directory is does get processed)

whats the asiest way for me to tell it to allow html files to be processed, docs not so clear for me thanks

davydotcom commented 8 years ago

Need to see your file structure all files are processed including html

Sent from my iPhone

On Apr 13, 2016, at 6:17 AM, E W notifications@github.com wrote:

Im using grails 3.1.3 which uses this plugin as far as I know.

For some reason my angular html templates are not getting processed by the plugin (however if i put a .js file in the directory is does get processed)

whats the asiest way for me to tell it to allow html files to be processed, docs not so clear for me thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

firex96 commented 8 years ago

I have same problem...at grails 3.14/3.1.5 and grails-asset-pipeline 3.x works on grails run-app or bootrun, but war file has no template js(for tpl.htm)...T.T

and maybe same reason - AngularJs Annotate Asset-Pipeline not working...

walshe commented 8 years ago

I got around my issues.. https://github.com/grails/grails-profile-repository/issues/69#issuecomment-209396158

just be careful with the convention for the templates - i.e. the naming of the html file and the fact that you are supposed to leave out '/templates/' from the url

firex96 commented 8 years ago

@walshe are you OK with making and running war?

walshe commented 8 years ago

didn't try yet actually, what should I test exactly.. I can try

firex96 commented 8 years ago

@walshe grails -Dgrails.env=dev war java -Dgrails.env=dev -jar build/libs/your.war and check template...plz...

thx...^^

walshe commented 8 years ago

ok i checked there all seems fine, my proj uses the asset pipeline so when I look in the chrome console for example I just see a minified blob of js.
However if I unzip the war and have a look inside the assets folder I can drill down and see the templates folder. In there I can see the relevant files... remember that the html files templates are processed into a .js file that has some clever code inside it e.g. angular.module("my.app.bla").run(["$templateCache",function(a){a.put ...

also, if you are runnig the war from the command line make sure you cd into the build/libs folder first otherwise grails gets confused with paths ( https://github.com/grails/grails-core/issues/9302 ).

Are you sure you have the naming convention on the templates correct ? and also the convention for the path in the $routeProvider config

$routeProvider. when('/unauthenticated', { templateUrl: "/myapp/core/unauthenticated.html", //NOTICE /templates/ omitted from path controller: "AuthenticationController as ctrl" })

davydotcom commented 8 years ago

whats your build.gradle?

walshe commented 8 years ago

heres mine

`buildscript { ext { grailsVersion = project.grailsVersion } repositories { mavenLocal() maven { url "https://repo.grails.org/grails/core" } } dependencies {

    classpath "org.grails:grails-gradle-plugin:$grailsVersion"
    classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.6.4"
    classpath "gradle.plugin.com.craigburke.gradle:karma-gradle:1.4.3"
    classpath "gradle.plugin.com.craigburke.gradle:bower-installer-gradle:2.5.1"
    classpath "org.grails.plugins:hibernate4:5.0.2"
    classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.5.0"
    classpath "org.grails.plugins:views-gradle:1.0.4"
    classpath "net.saliman:gradle-cobertura-plugin:2.3.1"

}

}

version "0.1" group "uk.xxx.xxx"

apply plugin:"eclipse" apply plugin:"idea" apply plugin:"war" apply plugin:"org.grails.grails-web" apply plugin:"org.grails.grails-gsp" apply plugin:"com.craigburke.karma" apply plugin:"com.craigburke.bower-installer" apply plugin:"asset-pipeline" apply plugin:"org.grails.plugins.views-json" apply plugin:"net.saliman.cobertura"

ext { grailsVersion = project.grailsVersion gradleWrapperVersion = project.gradleWrapperVersion }

repositories { mavenLocal() maven { url "https://repo.grails.org/grails/core" } maven { url "http://maven.restlet.org" } //needed for solr core lib }

dependencyManagement { imports { mavenBom "org.grails:grails-bom:$grailsVersion" } applyMavenExclusions false }

dependencies {

testRuntime 'cglib:cglib-nodep:3.2.1' //add to add this to get around spock/cglib/asm conflicts for SearchControllerSpec

assets "com.craigburke.angular:angular-template-asset-pipeline:2.2.6"
assets "com.craigburke.angular:angular-annotate-asset-pipeline:2.4.0"
assets "com.craigburke:js-closure-wrap-asset-pipeline:1.2.0"
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-plugin-url-mappings"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-codecs"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-datasource"
compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-async"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails.plugins:cache"
compile "org.grails:grails-plugin-gsp"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-ehcache"
compile "org.grails.plugins:views-json"
console "org.grails:grails-console"

//solr and rest stuff
compile('org.springframework.boot:spring-boot-starter-data-rest')
compile('org.springframework.boot:spring-boot-starter-data-solr')

//for embedded server
compile ('org.apache.solr:solr-core:4.10.4') {
    exclude(group: "org.slf4j", module: "slf4j-jdk14")
    exclude(group: "ch.qos.logback", module: "logback-classic")
}

compile "org.grails.plugins:grails3-cas-client:3.0"
compile "org.ccil.cowan.tagsoup:tagsoup:1.2"
//compile 'org.grails.plugins:quartz:2.0.1' // this version doesnt seem to work
compile 'org.grails.plugins:quartz:2.0.0.M4'

profile "org.grails.profiles:angular:3.1.3"
runtime "com.h2database:h2"
runtime "org.grails.plugins:asset-pipeline"
runtime 'org.grails.plugins:grails-console:2.0.4'

testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testCompile "org.grails:grails-datastore-rest-client"
//testCompile 'org.mockito:mockito-all:1.10.19'

testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"

//testRuntime "org.slf4j:slf4j-api:1.7.10" //stop cobertura class not found exception

}

task wrapper(type: Wrapper) { gradleVersion = gradleWrapperVersion } bower { 'angular'('1.4.x') { source 'angular.js' } 'angular-resource'('1.4.x') { source 'angular-resource.js' >> '/angular/' } 'angular-route'('1.4.x') { source 'angular-route.js' >> '/angular/' } 'angular-mocks'('1.4.x') { source 'angular-mocks.js' >> '/angular/' } 'angular-bootstrap'('1.1.x') { source 'ui-bootstrap-tpls.js' >> '/angular/' } 'bootstrap'('3.x.x') { source 'dist/css/bootstrap.css' >> '/bootstrap/' } 'underscore'('1.8.x') { source 'underscore.js' } 'ng-notify'('0.7.1')

}

karma { dependencies(['karma-wrap-preprocessor'])

profile 'angularJS'

preprocessors = [
    'grails-app/assets/javascripts/**/*.js': ['wrap']
]

wrapPreprocessor = [
    template: "(function () { 'use strict';  <%= contents %> })()"
]

}

assets { minifyJs = true minifyCss = true } `

hiddenkirby commented 7 years ago

This, unfortunately, did not solve my issue. When I run 'grails war' i notice the converted templateName.js files in my webapps/myApp/assets .. but those js files created do not come bundled in my application.js.

For me, it's Grails 3.1.10, asset-pipeline-gradle 2.8.2, and angular-template-asset-pipeline 2.2.6

davydotcom commented 7 years ago

What is at the top of the application js file?

On Jan 23, 2017, at 9:50 AM, Ryan Kirby notifications@github.com wrote:

davydotcom commented 7 years ago

Also what folder exactly are the templates in

On Jan 23, 2017, at 9:50 AM, Ryan Kirby notifications@github.com wrote:

hiddenkirby commented 7 years ago

Templates are exactly located in grails-app/assets/javascripts/myApp/templates

The top of the application.js is specifically moment.js for me. Everything else besides the templateName.js files seems to be bundling in ( i have yet to get it to minify, however ).

Works great in run-app.

When 'grails war' is used, is any of the assets configurations from application.groovy used? Or is it strictly from the build.grade file?

hiddenkirby commented 7 years ago

If my application.groovy has some assets configuration (per environment), and my build.gradle file has assets configuration... and i run 'grails war -Dgrails.env=development' does it pull configurations from application.groovy over build.gradle?

hiddenkirby commented 7 years ago

After i figured out which config file the configuraitons where coming from (run-app -> application.groovy, grails war -> build.gradle) ... i figured it out.

I got it to work with the following steps...

  1. I moved all my templateUrl: 'file.html' calls to templateUrl: '/myApp/file.html' (directives and view code)
  2. i set my "includePathInName= true"
  3. i put my .tpl.html files in grails-app/assets/javascripts/myApp/templates

Important takeaway here is that grails-app/assets/javascripts/templates would not work for me.

robsonolivesa commented 7 years ago

I am having the same problem (grails 3.1.14). The above solution did not work. Anyone have another suggestion?

ahummel25 commented 7 years ago

I'm having similar issue where my wrapped app.js gets initialized but the config does not. So therefore my UploadCtrl never gets instantiated.

` //= wrapped //= require /angular/angular //= require /angular/angular-resource //= require /angular/angular-route //= require UploadCtrl //= require_self //= require_tree services (function (angular) { 'use strict';

var ngModule = angular.module('item-upload', [
    'ngRoute',
    'ngAnimate',
    'item-upload.UploadCtrl'
]);

// Configure routing
ngModule.config(['$routeProvider', function ($routeProvider) {
    $routeProvider.when('/item-upload', {templateUrl: 'html/index.html', controller: 'UploadCtrl', pageName: 'upload'});

}]);

// Configure HTTP interceptors
ngModule.config(['$httpProvider', function ($httpProvider) {
    $httpProvider.interceptors.push('httpErrorHandler');
    $httpProvider.interceptors.push('sessionTimeoutHttpHandler');
    $httpProvider.defaults.withCredentials = true;
}]);

}(window.angular));

`