JHipster Docker Build with UI Grid not showing fonts - angularjs
I am using JHipster 3.8 with UI-Grid i.e. ui-grid.info when i run the application locally its working fine. But when i deploy to Docker using this command
./gradlew bootRepackage -Pprod buildDocker
docker-compose -f src/main/docker/app.yml up
i can see below error in developer console regarding fonts
generated.js:174220 GET http://192.168.99.100:8585/content/css/ui-grid-f53764c7a4.woff
GET http://192.168.99.100:8585/content/css/ui-grid-c6fa199a3e.ttf
and the page display with some character instead of icon as below :-
i have got couple solution for UI Grid link1 link2, but its not working for me, because as per the error file name and location are different, as gulp making such changes.
Not sure how to fix this issue. Can some once guide me?
EDIT
My Gulp File:-
// Generated on 2016-09-20 using generator-jhipster 3.7.1
'use strict';
var gulp = require('gulp'),
expect = require('gulp-expect-file'),
es = require('event-stream'),
flatten = require('gulp-flatten'),
sass = require('gulp-sass'),
rev = require('gulp-rev'),
templateCache = require('gulp-angular-templatecache'),
htmlmin = require('gulp-htmlmin'),
imagemin = require('gulp-imagemin'),
ngConstant = require('gulp-ng-constant'),
rename = require('gulp-rename'),
eslint = require('gulp-eslint'),
argv = require('yargs').argv,
gutil = require('gulp-util'),
protractor = require('gulp-protractor').protractor,
del = require('del'),
runSequence = require('run-sequence'),
browserSync = require('browser-sync'),
KarmaServer = require('karma').Server,
plumber = require('gulp-plumber'),
changed = require('gulp-changed'),
gulpIf = require('gulp-if');
var handleErrors = require('./gulp/handle-errors'),
serve = require('./gulp/serve'),
util = require('./gulp/utils'),
copy = require('./gulp/copy'),
inject = require('./gulp/inject'),
build = require('./gulp/build');
var config = require('./gulp/config');
gulp.task('clean', function () {
return del([config.dist], { dot: true });
});
gulp.task('copy', ['copy:i18n', 'copy:fonts', 'copy:common']);
gulp.task('copy:i18n', copy.i18n);
gulp.task('copy:languages', copy.languages);
gulp.task('copy:fonts', copy.fonts);
gulp.task('copy:common', copy.common);
gulp.task('copy:swagger', copy.swagger);
gulp.task('copy:images', copy.images);
gulp.task('images', function () {
return gulp.src(config.app + 'content/images/**')
.pipe(plumber({errorHandler: handleErrors}))
.pipe(changed(config.dist + 'content/images'))
.pipe(imagemin({optimizationLevel: 5, progressive: true, interlaced: true}))
.pipe(rev())
.pipe(gulp.dest(config.dist + 'content/images'))
.pipe(rev.manifest(config.revManifest, {
base: config.dist,
merge: true
}))
.pipe(gulp.dest(config.dist))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('sass', function () {
return es.merge(
gulp.src(config.sassSrc)
.pipe(plumber({errorHandler: handleErrors}))
.pipe(expect(config.sassSrc))
.pipe(changed(config.cssDir, {extension: '.css'}))
.pipe(sass({includePaths:config.bower}).on('error', sass.logError))
.pipe(gulp.dest(config.cssDir)),
gulp.src(config.bower + '**/fonts/**/*.{woff,woff2,svg,ttf,eot,otf}')
.pipe(plumber({errorHandler: handleErrors}))
.pipe(changed(config.app + 'content/fonts'))
.pipe(flatten())
.pipe(gulp.dest(config.app + 'content/fonts'))
);
});
gulp.task('copyAngularUiGridFonts', function() {
gulp.src(config.app + '/bower_components/angular-ui-grid/*.{ttf,woff,eof,svg}')
.pipe(gulp.dest(config.dist + 'content/css/'));
});
gulp.task('styles', ['sass'], function () {
return gulp.src(config.app + 'content/css')
.pipe(browserSync.reload({stream: true}));
});
gulp.task('inject', function() {
runSequence('inject:dep', 'inject:app');
});
gulp.task('inject:dep', ['inject:test', 'inject:vendor']);
gulp.task('inject:app', inject.app);
gulp.task('inject:vendor', inject.vendor);
gulp.task('inject:test', inject.test);
gulp.task('inject:troubleshoot', inject.troubleshoot);
gulp.task('assets:prod', ['images', 'styles', 'html', 'copy:swagger', 'copy:images'], build);
gulp.task('html', function () {
return gulp.src(config.app + 'app/**/*.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(templateCache({
module: 'dashboardApp',
root: 'app/',
moduleSystem: 'IIFE'
}))
.pipe(gulp.dest(config.tmp));
});
gulp.task('ngconstant:dev', function () {
return ngConstant({
name: 'dashboardApp',
constants: {
VERSION: util.parseVersion(),
DEBUG_INFO_ENABLED: true
},
template: config.constantTemplate,
stream: true
})
.pipe(rename('app.constants.js'))
.pipe(gulp.dest(config.app + 'app/'));
});
gulp.task('ngconstant:prod', function () {
return ngConstant({
name: 'dashboardApp',
constants: {
VERSION: util.parseVersion(),
DEBUG_INFO_ENABLED: false
},
template: config.constantTemplate,
stream: true
})
.pipe(rename('app.constants.js'))
.pipe(gulp.dest(config.app + 'app/'));
});
/*gulp.task('fonts:prod', function () {
return gulp.src($.mainBowerFiles())
.pipe($.filter(config.bower + 'angular-ui-grid/*.{eot,svg,ttf,woff,woff2}'))
.pipe($.flatten())
.pipe(gulp.dest(options.tmp + 'content/css/'));
});*/
// check app for eslint errors
gulp.task('eslint', function () {
return gulp.src(['gulpfile.js', config.app + 'app/**/*.js'])
.pipe(plumber({errorHandler: handleErrors}))
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
// check app for eslint errors anf fix some of them
gulp.task('eslint:fix', function () {
return gulp.src(config.app + 'app/**/*.js')
.pipe(plumber({errorHandler: handleErrors}))
.pipe(eslint({
fix: true
}))
.pipe(eslint.format())
.pipe(gulpIf(util.isLintFixed, gulp.dest(config.app + 'app')));
});
gulp.task('test', ['inject:test', 'ngconstant:dev'], function (done) {
new KarmaServer({
configFile: __dirname + '/' + config.test + 'karma.conf.js',
singleRun: true
}, done).start();
});
/* to run individual suites pass `gulp itest --suite suiteName` */
gulp.task('protractor', function () {
var configObj = {
configFile: config.test + 'protractor.conf.js'
};
if (argv.suite) {
configObj['args'] = ['--suite', argv.suite];
}
return gulp.src([])
.pipe(plumber({errorHandler: handleErrors}))
.pipe(protractor(configObj))
.on('error', function () {
gutil.log('E2E Tests failed');
process.exit(1);
});
});
gulp.task('itest', ['protractor']);
gulp.task('watch', function () {
gulp.watch('bower.json', ['install']);
gulp.watch(['gulpfile.js', 'build.gradle'], ['ngconstant:dev']);
gulp.watch(config.sassSrc, ['styles']);
gulp.watch(config.app + 'content/images/**', ['images']);
gulp.watch(config.app + 'app/**/*.js', ['inject:app']);
gulp.watch([config.app + '*.html', config.app + 'app/**', config.app + 'i18n/**']).on('change', browserSync.reload);
});
gulp.task('install', function () {
runSequence(['inject:dep', 'ngconstant:dev'], 'sass', 'copy:languages', 'inject:app', 'inject:troubleshoot');
});
gulp.task('serve', ['install'], serve);
gulp.task('build', ['clean'], function (cb) {
runSequence(['copy','copyAngularUiGridFonts', 'inject:vendor', 'ngconstant:prod', 'copy:languages'], 'inject:app', 'inject:troubleshoot', 'assets:prod', cb);
});
gulp.task('default', ['serve']);
EDIT:-
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url "http://repo.spring.io/plugins-release" }
maven { url "http://repo.spring.io/milestone" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.0.1"
classpath "net.ltgt.gradle:gradle-apt-plugin:0.6"
classpath "org.springframework.boot:spring-boot-gradle-plugin:${spring_boot_version}"
classpath "org.springframework.build.gradle:propdeps-plugin:0.0.7"
classpath "com.moowork.gradle:gradle-node-plugin:0.12"
classpath "com.moowork.gradle:gradle-gulp-plugin:0.12"
classpath "se.transmode.gradle:gradle-docker:1.2"
classpath "io.spring.gradle:dependency-management-plugin:0.5.6.RELEASE"
//jhipster-needle-gradle-buildscript-dependency - JHipster will add additional gradle build script plugins here
}
}
apply plugin: 'java'
sourceCompatibility=1.8
targetCompatibility=1.8
apply plugin: 'maven'
apply plugin: 'spring-boot'
apply plugin: 'war'
apply plugin: 'propdeps'
apply plugin: 'io.spring.dependency-management'
/* downgrade Hibernate to 4.3 */
ext['hibernate.version'] = '${hibernate_entitymanager_version}'
defaultTasks 'bootRun'
sourceSets {
generated {
java {
srcDirs = ['src/main/generated']
}
}
}
bootRepackage {
mainClass = 'com.equidity.dashboard.XboardApp'
}
war {
}
springBoot {
mainClass = 'com.equidity.dashboard.XboardApp'
executable = true
buildInfo()
}
bootRun {
addResources = false
}
apply from: 'gradle/yeoman.gradle'
apply from: 'gradle/sonar.gradle'
apply from: 'gradle/liquibase.gradle'
apply from: 'gradle/gatling.gradle'
apply from: 'gradle/mapstruct.gradle'
apply from: 'gradle/docker.gradle'
//jhipster-needle-gradle-apply-from - JHipster will add additional gradle scripts to be applied here
if (project.hasProperty('prod')) {
apply from: 'gradle/profile_prod.gradle'
} else {
apply from: 'gradle/profile_dev.gradle'
}
group = 'com.equidity.dashboard'
version = '0.0.1-SNAPSHOT'
description = ''
configurations {
providedRuntime
compile.exclude module: "spring-boot-starter-tomcat"
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url 'http://repo.spring.io/milestone' }
maven { url 'http://repo.spring.io/snapshot' }
maven { url 'https://repository.jboss.org/nexus/content/repositories/releases' }
maven { url 'https://oss.sonatype.org/content/repositories/releases' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'http://repo.maven.apache.org/maven2' }
}
dependencies {
compile "io.dropwizard.metrics:metrics-core"
compile "io.dropwizard.metrics:metrics-graphite:${dropwizard_metrics_version}"
compile "io.dropwizard.metrics:metrics-healthchecks:${dropwizard_metrics_version}"
compile "io.dropwizard.metrics:metrics-jvm:${dropwizard_metrics_version}"
compile "io.dropwizard.metrics:metrics-servlet:${dropwizard_metrics_version}"
compile "io.dropwizard.metrics:metrics-json:${dropwizard_metrics_version}"
compile ("io.dropwizard.metrics:metrics-servlets:${dropwizard_metrics_version}") {
exclude(module: 'metrics-healthchecks')
}
compile("net.logstash.logback:logstash-logback-encoder:${logstash_logback_encoder_version}") {
exclude(module: 'ch.qos.logback')
}
compile "com.fasterxml.jackson.datatype:jackson-datatype-json-org:${jackson_version}"
compile "com.fasterxml.jackson.datatype:jackson-datatype-hppc:${jackson_version}"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${jackson_version}"
compile "com.fasterxml.jackson.datatype:jackson-datatype-hibernate4"
compile "com.fasterxml.jackson.core:jackson-annotations:${jackson_version}"
compile "com.fasterxml.jackson.core:jackson-databind:${jackson_version}"
compile ("com.ryantenney.metrics:metrics-spring:${metrics_spring_version}") {
exclude(module: 'metrics-core')
exclude(module: 'metrics-healthchecks')
}
compile "com.hazelcast:hazelcast:${hazelcast_version}"
compile "com.hazelcast:hazelcast-hibernate4:${hazelcast_version}"
compile "com.hazelcast:hazelcast-spring:${hazelcast_version}"
compile "com.hazelcast:hazelcast-wm:${hazelcast_version}"
compile "org.hibernate:hibernate-core:${hibernate_entitymanager_version}"
compile("com.zaxxer:HikariCP:${HikariCP_version}") {
exclude(module: 'tools')
}
compile "org.apache.commons:commons-lang3:${commons_lang_version}"
compile "commons-io:commons-io:${commons_io_version}"
compile "javax.inject:javax.inject:${javax_inject_version}"
compile "javax.transaction:javax.transaction-api"
compile "org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:${geronimo_javamail_1_4_mail_version}"
compile "org.hibernate:hibernate-envers"
compile "org.hibernate:hibernate-validator"
compile ("org.liquibase:liquibase-core:${liquibase_core_version}") {
exclude(module: 'jetty-servlet')
}
compile "com.mattbertolini:liquibase-slf4j:${liquibase_slf4j_version}"
compile "org.springframework.boot:spring-boot-actuator"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.springframework.boot:spring-boot-loader-tools"
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-aop"
compile "org.springframework.boot:spring-boot-starter-data-jpa"
compile "org.springframework.boot:spring-boot-starter-data-elasticsearch"
// needed to get around elasticsearch stacktrace about jna not found
// https://github.com/elastic/elasticsearch/issues/13245
compile "net.java.dev.jna:jna:${jna_version}"
compile "org.springframework.boot:spring-boot-starter-security"
compile ("org.springframework.boot:spring-boot-starter-web") {
exclude module: 'spring-boot-starter-tomcat'
}
compile "org.springframework.boot:spring-boot-starter-undertow"
compile "org.springframework.boot:spring-boot-starter-websocket"
compile "org.springframework.boot:spring-boot-starter-thymeleaf"
compile "org.springframework.cloud:spring-cloud-cloudfoundry-connector"
compile "org.springframework.cloud:spring-cloud-spring-service-connector"
compile "org.springframework.cloud:spring-cloud-localconfig-connector"
compile ("org.springframework:spring-context-support") {
exclude(module: 'quartz')
}
compile "org.springframework.security:spring-security-config:${spring_security_version}"
compile "org.springframework.security:spring-security-data:${spring_security_version}"
compile "org.springframework.security:spring-security-web:${spring_security_version}"
compile "org.springframework.security:spring-security-messaging:${spring_security_version}"
compile("io.springfox:springfox-swagger2:${springfox_version}"){
exclude module: 'mapstruct'
}
compile "mysql:mysql-connector-java"
compile "fr.ippon.spark.metrics:metrics-spark-reporter:${metrics_spark_reporter_version}"
compile "org.mapstruct:mapstruct-jdk8:${mapstruct_version}"
compile "org.apache.httpcomponents:httpclient"
compile "org.springframework.social:spring-social-security"
compile "org.springframework.social:spring-social-google:${spring_social_google_version}"
compile "org.springframework.social:spring-social-facebook"
compile "org.springframework.social:spring-social-twitter"
testCompile "com.jayway.awaitility:awaitility:${awaility_version}"
testCompile "com.jayway.jsonpath:json-path"
testCompile "info.cukes:cucumber-junit:${cucumber_version}"
testCompile "info.cukes:cucumber-spring:${cucumber_version}"
testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile "org.springframework.security:spring-security-test"
testCompile "org.springframework.boot:spring-boot-test"
testCompile "org.assertj:assertj-core:${assertj_core_version}"
testCompile "junit:junit"
testCompile "org.mockito:mockito-core"
testCompile "com.mattbertolini:liquibase-slf4j:${liquibase_slf4j_version}"
testCompile "org.hamcrest:hamcrest-library"
testCompile "io.gatling.highcharts:gatling-charts-highcharts:${gatling_version}"
testCompile "com.h2database:h2"
optional "org.springframework.boot:spring-boot-configuration-processor:${spring_boot_version}"
//jhipster-needle-gradle-dependency - JHipster will add additional dependencies here
compile "com.querydsl:querydsl-core:${queryDslVersion}"
compile "com.querydsl:querydsl-jpa:${queryDslVersion}"
compile "com.querydsl:querydsl-apt:${queryDslVersion}"
querydslapt "com.querydsl:querydsl-apt:${queryDslVersion}"
}
clean {
delete "target"
}
task cleanResources(type: Delete) {
delete 'build/resources'
}
task wrapper(type: Wrapper) {
gradleVersion = '3.1'
}
task stage(dependsOn: 'bootRepackage') {
}
compileJava.dependsOn processResources
processResources.dependsOn cleanResources,bootBuildInfo
bootBuildInfo.mustRunAfter cleanResources
EDIT :- Profile_prod.gradle
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'spring-boot'
apply plugin: 'com.moowork.node'
apply plugin: 'com.moowork.gulp'
ext {
logbackLoglevel = "INFO"
}
dependencies {
}
def profiles = 'prod'
if (project.hasProperty('no-liquibase')) {
profiles += ',no-liquibase'
}
if (project.hasProperty('swagger')) {
profiles += ',swagger'
}
bootRun {
args = []
}
task gulpBuildWithOpts(type: GulpTask) {
args = ["build", "--no-notification"]
}
war {
webAppDirName = 'build/www/'
}
processResources {
filesMatching('**/logback-spring.xml') {
filter {
it.replace('#logback.loglevel#', logbackLoglevel)
}
}
filesMatching('**/application.yml') {
filter {
it.replace('#spring.profiles.active#', profiles)
}
}
}
gulpBuildWithOpts.dependsOn 'npmInstall'
gulpBuildWithOpts.dependsOn 'bower'
processResources.dependsOn gulpBuildWithOpts
test.dependsOn gulp_test
bootRun.dependsOn gulp_test
As described in in the links that you provided, you need a task in gulpfile.js which copy the missing files. You can use the following code to your existing copy task e.g.:
gulp.src(config.app + '/bower_components/angular-ui-grid/*.{ttf,woff,eof,svg}')
.pipe(plumber({errorHandler: handleErrors}))
.pipe(changed(config.dist + 'content/css/'))
.pipe(flatten())
.pipe(rev())
.pipe(gulp.dest(config.dist + 'content/css/'))
.pipe(rev.manifest(config.revManifest, {
base: config.dist,
merge: true
}))
.pipe(gulp.dest(config.dist)),
i.e. your copy task is gone look like this:
gulp.task('copy', function () {
return es.merge(
gulp.src(config.app + 'i18n/**')
.pipe(plumber({errorHandler: handleErrors}))
.pipe(changed(config.dist + 'i18n/'))
.pipe(gulp.dest(config.dist + 'i18n/')),
gulp.src(config.bower + 'bootstrap/fonts/*.*')
.pipe(plumber({errorHandler: handleErrors}))
.pipe(changed(config.dist + 'content/fonts/'))
.pipe(rev())
.pipe(gulp.dest(config.dist + 'content/fonts/'))
.pipe(rev.manifest(config.revManifest, {
base: config.dist,
merge: true
}))
.pipe(gulp.dest(config.dist)),
gulp.src(config.app + '/bower_components/angular-ui-grid/*.{ttf,woff,eof,svg}')
.pipe(plumber({errorHandler: handleErrors}))
.pipe(changed(config.dist + 'content/css/'))
.pipe(flatten())
.pipe(rev())
.pipe(gulp.dest(config.dist + 'content/css/'))
.pipe(rev.manifest(config.revManifest, {
base: config.dist,
merge: true
}))
.pipe(gulp.dest(config.dist)),
gulp.src(config.app + 'content/**/*.{woff,woff2,svg,ttf,eot,otf}')
.pipe(plumber({errorHandler: handleErrors}))
.pipe(changed(config.dist + 'content/fonts/'))
.pipe(flatten())
.pipe(rev())
.pipe(gulp.dest(config.dist + 'content/fonts/'))
.pipe(rev.manifest(config.revManifest, {
base: config.dist,
merge: true
}))
.pipe(gulp.dest(config.dist)),
gulp.src([config.app + 'robots.txt', config.app + 'favicon.ico', config.app + '.htaccess'], { dot: true })
.pipe(plumber({errorHandler: handleErrors}))
.pipe(changed(config.dist))
.pipe(gulp.dest(config.dist))
);
});
Its looks like angular-grid-ui is expecting the *.{ttf,woff,eof,svg} files to be found under the content/css and not content/fonts
Related
How to enable Hot Module Replacement (HMR) for a directory outside of src in a React app?
I have a React app that uses an external shared directory at the top level, shared-js, that is located outside of the src directory of my app. I want to enable Hot Module Replacement (HMR) for this shared module so that I can see changes to it in real-time without having to reload the entire app (for example if I change a console.log within a file in that directory). I have already tried adding webpack.HotModuleReplacementPlugin() to my webpack.config.js file and adding the following code to my index.js file in the shared-js module: if (module.hot) { module.hot.accept();} However, HMR still does not work for changes made to the shared-js module. How can I enable HMR for the shared-js module in my React app? What I have tried: Adding webpack.HotModuleReplacementPlugin() to webpack.config.js Adding if (module.hot) { module.hot.accept(); } to index.js in shared-js Code: Here is my current webpack.config.js file: const paths = require("./paths"); module.exports = { entry: { main: paths.appIndexJs, shared: "../libs/shared-js/index.js", }, output: { path: paths.appBuild, filename: "[name].bundle.js", }, module: { rules: [ // ... ], }, plugins: [ // ... new webpack.HotModuleReplacementPlugin(), ], // ... }; And here is my index.js file in shared-js: 'use strict'; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./types"), exports); __exportStar(require("./core"), exports); __exportStar(require("./testing"), exports); if (module.hot) { module.hot.accept(); } As someone new to React/web dev, I would like to clarify if hot reloading is what I need to change in order to have React automatically update files to browser without the need to rerun yarn start, or if there is something else that must be changed. Thank you!
How to use custom style loader in Vite
We have a react project and using webpack for bundling but also we want to try vite too. Webpack bundle css files from style-loader.js too. In style-loader.js we have some rules which are related to components and components are added to node modules. My rule's aim is mainly importing css files from node_modules components. When we run our project with vite, Our custom scss files does not override css which came from components. Is there any solution for override or Is there any way to use a custom style loader in vite ? Our custom style loader webpack-dev is; module: { rules: [ { test: /\.js?$/, exclude: /(node_modules|bower_components)/, loader: './config/webpack/style-loader' }, ]} Our style-loader.js file is; const babylon = require('babylon'); const traverse = require('babel-traverse').default; const fs = require('fs'); module.exports = function (source) { var astResult = babylon.parse(source, { sourceType: "module", ranges: true, plugins: [ "jsx", "objectRestSpread", "flow", "typescript", "decorators", "doExpressions", "classProperties", "classPrivateProperties", "classPrivateMethods", "exportExtensions", "asyncGenerators", "functionBind", "functionSent", "dynamicImport", "numericSeparator", "optionalChaining", "importMeta", "bigInt", "optionalCatchBinding" ] }); let addedIndexCounter = 0; let isViewDirty = false; traverse(astResult, { enter: function (path) { let node = path.node; if (node.type == 'ImportDeclaration' && node.source && node.source.type == 'StringLiteral' && node.source.value && node.source.value.indexOf('#packagename') >= 0 && node.source.value.indexOf('core') < 0 && node.source.value.indexOf('.css') < 0) { if(fs.existsSync('./node_modules/' + node.source.value + '/styles.css')) { let starting = node.end; starting += addedIndexCounter; let targettacCss = "; import '" + node.source.value + "/styles.css';" addedIndexCounter += targettacCss.length; source = source.substring(0, starting) + targettacCss + source.substring(starting); isViewDirty = true; } } } }); /*if(isViewDirty){ let fileName = "view_" + (new Date()).toISOString().slice(0, 10)+"_" + Math.random().toString(35).substr(2,10); fs.writeFileSync('./logs/views/' + fileName, source); }*/ return source; };
You can use plugins to achieve your feature, the following is my general idea. // vite.config.js import { defineConfig } from "vite"; import customerPlugin from "./plugin/customer-plugin"; export default defineConfig(() => { return { // .. plugins: [customerPlugin()] // Put your plugin here }; }); // ./plugin/customer-plugin.js const customerPlugin = () => { return { name: "customer-transform", transform(code, id) { // id = "/some/path/xxx.js" if (!id.endsWith(".js")) return; // Only transform js file. let resultCode = ""; // Paste your transform logic here. return resultCode; } }; }; export default customerPlugin; reference: https://vitejs.dev/guide/api-plugin.html
Nullpointer on standalone .jar org.apache.cxf.wsdl11.WSDLServiceFactory
I have a grpc's micronaut project and I have a gradle task to generate java classes from a wsdl. The build is success but when I launch the grpc server and call a method that uses one of the generated classes I get the following error: Caused by: java.lang.NullPointerException: null at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:85) at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:218) at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:161) at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:129) at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:99) at javax.xml.ws.Service.<init>(Service.java:77) Here is my build.gradle plugins { id "io.spring.dependency-management" version "1.0.6.RELEASE" id "com.google.protobuf" version "0.8.5" id "java" id "net.ltgt.apt-eclipse" version "0.21" id "net.ltgt.apt-idea" version "0.21" id "com.github.johnrengelman.shadow" version "4.0.2" id "application" id "no.nils.wsdl2java" version "0.10" id "net.ltgt.apt" version "0.8" id "groovy" id "jacoco" } version "1.0.0" group "com.myproject" repositories { mavenCentral() maven { url "https://jcenter.bintray.com" } } dependencyManagement { imports { mavenBom 'io.micronaut:micronaut-bom:1.1.4' } } configurations { // for dependencies that are needed for development only developmentOnly } dependencies { compileOnly 'org.projectlombok:lombok:1.18.2' annotationProcessor "org.projectlombok:lombok:1.18.2" annotationProcessor "io.micronaut:micronaut-inject-java" annotationProcessor "io.micronaut:micronaut-validation" compile "io.micronaut.grpc:micronaut-grpc-runtime" compile "io.micronaut:micronaut-inject" compile "io.micronaut:micronaut-validation" compile "io.micronaut:micronaut-runtime" runtime "ch.qos.logback:logback-classic:1.2.3" compile "org.mapstruct:mapstruct:1.3.0.Final" annotationProcessor "org.mapstruct:mapstruct-processor:1.3.0.Final" compile group: 'org.apache.cxf', name: 'cxf-rt-bindings-soap', version: '3.3.2' compile group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxws', version: '3.0.2' compile group: 'org.apache.cxf', name: 'cxf-rt-transports-http', version: '3.3.2' compile group: 'org.apache.cxf', name: 'cxf-rt-ws-security', version: '3.1.11' testCompileOnly platform("io.micronaut:micronaut-bom:$micronautVersion") testImplementation("org.spockframework:spock-core") { exclude group: "org.codehaus.groovy", module: "groovy-all" } testImplementation "io.micronaut:micronaut-inject-groovy" testImplementation "io.micronaut.test:micronaut-test-spock" testImplementation "io.micronaut.test:micronaut-test-junit5" testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.5.0" } test.classpath += configurations.developmentOnly mainClassName = "com.myproject.Application" ext { protocVersion="3.5.1" grpcVersion="1.18.0" } sourceSets { main { java { srcDirs 'build/generated/source/proto/main/grpc' srcDirs 'build/generated/source/proto/main/java' } } } protobuf { protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" } plugins { grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" } } generateProtoTasks { all()*.plugins { grpc {} } } } // use JUnit 5 platform test { useJUnitPlatform() } tasks.withType(JavaCompile){ options.encoding = "UTF-8" options.compilerArgs.add('-parameters') } shadowJar { mergeServiceFiles() } wsdl2java{ wsdlsToGenerate = [ ['-exsh', 'true','-p','com.myproject', '-autoNameResolution', "-b", "$projectDir/src/main/resources/wsdl/bindings.xml", "$projectDir/src/main/resources/wsdl/v1_1.wsdl"] ] wsdlDir = file("$projectDir/src/main/resources/wsdl") locale = Locale.getDefault() } wsdl2javaExt { cxfVersion = "3.3.2" } run.classpath += configurations.developmentOnly run.jvmArgs('-noverify', '-XX:TieredStopAtLevel=1', '-Dcom.sun.management.jmxremote') tasks.withType(JavaCompile){ options.encoding = "UTF-8" options.compilerArgs.add('-parameters') } jacocoTestReport { reports { html { enabled true } } afterEvaluate { classDirectories.from = files(classDirectories.files.collect { fileTree(dir: it, exclude: ['**/Application*', 'com/myproject/**']) }) } } task buildWithCoverage { dependsOn 'clean' dependsOn 'cleanTest' dependsOn 'test' dependsOn 'jacocoTestReport' tasks.findByName('cleanTest').mustRunAfter 'clean' tasks.findByName('test').mustRunAfter 'cleanTest' tasks.findByName('jacocoTestReport').mustRunAfter 'test' } Any help?
Grunt usemin, get final path of compressed files to allow preload
I have a HTML block like this for minify css and js files: <!-- build:css static/assets/css/combined.css --> <link rel="stylesheet" href="static/bower_components/font-awesome/css/font-awesome.css"> <link rel="stylesheet" href="static/bower_components/photoswipe/dist/photoswipe.css" /> <link rel="stylesheet" href="static/bower_components/photoswipe/dist/default-skin/default-skin.css" /> <link rel="stylesheet" href="static/assets/css/jasny-bootstrap.min.css"> <link rel="stylesheet" href="static/assets/css/main.min.css"> <link rel="stylesheet" href="static/assets/css/custom.css"> <link rel="stylesheet" href="static/common/da-angular-spinkit/angular-spinkit.min.css"> <!-- endbuild --> I need to make a preload of the resource static/assets/css/combined.css but the final file has a hash at the end of its name, so the final path is like static/assets/css/combined.min-af5890ce41.css, so I don't know how to include the following tag: <link rel="preload" href="static/assets/css/combined.min-af5890ce41.css"/> -------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^ Because I don't know what is the final name of the generated minified file. How can I get the output of this generated file? I only need the final path name. I search about grunt-usemin but seems to be "minimalist". Thank you. EDIT I found on the project some pieces of grunt code if you can see what module is acting on the file hashes: /client/static/bower_components/bootstrap/Gruntfile.js: Here I can see: jshint uglify less csslint cssmin csscomb htmlmin I can't see what of this modules acts on the build:js or build:css in the index.html. /client/static/bower_components/photoswipe/Gruntfile.js: Here I can see npm tasks: grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-sass'); grunt.loadNpmTasks('grunt-autoprefixer'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-jekyll'); grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-aws-s3'); grunt.loadNpmTasks('grunt-svgmin'); EDIT 2 On the folder /dev/ there is a gruntfile.js with this code (it seems not related): var src = "../src/client/"; module.exports = function (grunt) { grunt.loadNpmTasks("grunt-angular-gettext"); // We extract translations with 'grunt nggettext_extract'. Those files go to '/dev/translations-extract' directory. grunt.initConfig({ nggettext_extract: { pot: { files: { 'translations-extract/template.pot': [src + 'static/common/**/*.html', src + 'static/states/**/*.html', src + 'index.html', src + 'indexMobile.html'] } }, }, // We compile those files (*.po) with 'grunt nggettext_compile. The translations.js file goes to /client/static/util/translations/ dir. nggettext_compile: { all: { options: { module: 'alvarez', }, files: { '../src/client/static/common/translations/translations.js': ['translations-extract/*.po'] } }, }, }) } And then, on /dev/bower_components/ there are tons of plugins, each one with its gruntfile.js inside. EDIT 3 Found on /ops/ a gulpfile.js and seems to be related /** * Crea una versión de distribución concatenada y minificada */ var gulp = require('gulp'); var run = require('gulp-run'); var gulpif = require('gulp-if'); var useref = require('gulp-useref'); var uglify = require('gulp-uglify'); var rename = require('gulp-rename'); var debug = require('gulp-debug'); var del = require('del'); var ngAnnotate = require('gulp-ng-annotate'); var minifyHTML = require('gulp-minify-html'); var cleanCSS = require('gulp-clean-css'); var rev = require('gulp-rev'); var revReplace = require('gulp-rev-replace'); var embedTemplates = require('./embed-templates/index.js'); var dist = './dist/'; var indexDist = dist + 'client/'; var HTMLDist = indexDist + 'static/'; var src = '../src/'; var assetsSrc = src + 'client/static/assets/' var cssSrc = assetsSrc + 'css/'; var serverDist = dist + 'server/'; var libDist = dist + 'lib/'; // pm2 // Init-dist gulp.task('pm2', function () { run('pm2 start ' + serverDist + 'alvarez.js').exec(); }); // Init-stop gulp.task('pm2-stop', function () { run('pm2 stop ' + serverDist + 'alvarez.js').exec(); }); //Init-restart gulp.task('pm2-restart', function () { run('pm2 restart ' + serverDist + 'alvarez.js').exec(); }); // npm-install on dist gulp.task('npm-install-dist', function () { run('npm install --production --prefix ' + serverDist).exec(); }) // Dist subtasks // Cleaning dist gulp.task('del-dist', function () { del(dist, { force: true }, console.log('Files deleted')); }); // Moving index.js gulp.task('move-server-js', function () { return gulp.src([src + 'server/alvarez.js', src + 'server/package.json']) .pipe(gulp.dest(serverDist)); }); gulp.task('move-config-js', function () { return gulp.src([src + 'server/lib/**/*.js']) .pipe(gulp.dest(serverDist + 'lib/')) }) //gulp.task('move-lib-js', function () { // return gulp.src(src + 'lib/config.js') // .pipe(gulp.dest(libDist)); //}); // //gulp.task('move-boot-pro', function () { // return gulp.src(src + 'lib/boot.pro.js') // .pipe(rename('boot.js')) // .pipe(gulp.dest(libDist)); //}) // Moving html gulp.task('move-html', function () { var opts = { empty: true }; return gulp.src([src + 'client/static/**/**/*.html', src + 'client/static/**/**/*.swf']) .pipe(minifyHTML(opts)) .pipe(gulp.dest(HTMLDist)); }); gulp.task('minify-css', ['move-assets', 'move-html-index', 'move-html-index-mobile'], function() { return gulp.src(HTMLDist + 'assets/css/*.css') .pipe(cleanCSS()) .pipe(gulp.dest(HTMLDist + 'assets/css/')); }) gulp.task('move-assets', function () { return gulp.src(src + '/client/static/assets/**/*.*') .pipe(gulp.dest(HTMLDist + 'assets/')); }); // Moving html index gulp.task('move-html-index', function () { var assets = useref.assets(); //.pipe(gulpif('**\/da-*.js', embedTemplates())) return gulp.src(src + 'client/index.html') .pipe(assets) .pipe(gulpif('*.js', embedTemplates())) .pipe(gulpif('.*\.js', ngAnnotate())) .pipe(gulpif('.*\.js', uglify())) .pipe(rev()) .pipe(assets.restore()) .pipe(useref()) .pipe(revReplace()) .pipe(debug()) .pipe(gulp.dest(indexDist)); }); gulp.task('move-html-index-mobile', function () { var assets = useref.assets(); return gulp.src(src + 'client/indexMobile.html') .pipe(assets) .pipe(gulpif('*.js', embedTemplates())) .pipe(gulpif('.*\.js', ngAnnotate())) .pipe(gulpif('.*\.js', uglify())) .pipe(assets.restore()) .pipe(useref()) .pipe(gulp.dest(indexDist)); }) gulp.task('embed-templates', [], function () { return gulp.src([src + 'client/static/states/**/da*/*.js', src + 'client/static/common/**/da*/*.js']) .pipe(gulpif('*.js', embedTemplates())) .pipe(ngAnnotate()) .pipe(uglify()) .pipe(gulp.dest(indexDist)) }); // Build dist task gulp.task('build-dist', ['move-html', 'move-server-js', 'move-config-js', 'minify-css'], function () { console.log('Dist ready...'); });
The answer is no in grunt-usemin, but in one of the dependencies: grunt-filerev. This last module is the one used to create the file revisions of you css, js and other files. After grunt-filerev is executed (executed as a subtask of grunt-usemin), it creates a summary (stored in within your grunt task, under grunt.filerev.summary). The summary contains the following information: { “original.js” : “destination.59bcc35a.js” } So you could use it later on you string replacement method/module of your choice. You can find more information about grunt-filerev here. Hope it helps.
Cordova/Ionic - How to remove external storage file and directory
I have tried to delete the whole directory(the folder + files under the folder) which files were downloaded into the external storage base directory: cordova.file.externalDataDirectory(like"file///storage/emulated/0/Android/data/com.yourapp/files"). But when I tried to remove the directory recursively by $cordovaFile,like below: var baseDirectory = cordova.file.externalDataDirectory + 'attachments'; $cordovaFile.removeRecursively(baseDirectory,"") .then(function(success){ console.log('Clear success'); },function(err){ loadingService.hideLoading(); }) It throws NO_MODIFICATION_ALLOWED error: While I check the folder permission, I do have the write/execute right. Any one has any idea why this happens? BTW, I have also tried the window.requestFileSystem, unfortunately, still don't work out.Since the filesystem is local file system, I tried to change the entry to external file system like entry.nativeURL = cordova.file.externalDataDirectory; But I guess it won't work since the reader has nothing there. So anyone has any suggestions on how to remove the whole directory? Thanks in advance! window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail); function fail(evt) { console.log("FILE SYSTEM FAILURE" + evt.target.error.code); } function onFileSystemSuccess(fileSystem) { fileSystem.root.getDirectory( "attachments", {create : true, exclusive : false}, function(entry) { console.log(entry); entry.nativeURL = cordova.file.externalDataDirectory; var reader = entry.createReader(); reader.readEntries( function(entries){ console.log(entries); }, function(err){ console.log(err); } ) entry.removeRecursively(function() { console.log('CLEAR success'); }, fail); }, fail); }
In case you are using Android Marshmallow, ensure to use latest version of cordova file plugin (4.2.0) as it has issues fixes related to permissions. The code snippet for directory deletion is as follows, function clearDirectory() { if (ionic.Platform.isAndroid()) { window.resolveLocalFileSystemURL(cordova.file.externalRootDirectory, onFileSystemDirSuccess, fail); } else { window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemDirSuccess, fail); } function onFileSystemDirSuccess(fileSystem) { var entry = ""; if (ionic.Platform.isAndroid()) { entry = fileSystem; } else { entry = fileSystem.root; } entry.getDirectory("DIRECTORY_TO_DELETE", { create: true, exclusive: false }, function(entry) { entry.removeRecursively(function() { console.log("Remove Recursively Succeeded"); }, fail); }, getDirFail); } function getDirFail(error) { navigator.notification.alert("Error"); }; function fail(error) { navigator.notification.alert("Error"); };