Develop plugins in sylius Best practice? - sylius

Is there a way to develop plugins in main directory of the project not in vendor.
A way to autoload the plugin ?

Yes, you can just declare a new Sylius Plugin. With this guidelines you should be able to start working on your bundle.
Just make sure to declare your custom Vendor in your Sylius roots composer.json:
...
"autoload": {
"psr-4": {
"App\\": "src/",
"Mgs\\SyliusThemePlugin\\": "lib/MgsSyliusThemePlugin/src"
}
},
...
Make sure to run composer dump-autoload afterwards, so that the Autoloader will catch upon your new code.

Related

Importing react-native package when running Vite

I am new to Vite and Vitest. I am experimenting a little bit, trying to add Vitest to a React-native app. I know Vite doesn't really support React Native but I would like to trying running just the tests with Vitest.
I get an error when trying to import React-native modules:
Module .../node_modules/react-native/index.js:14 seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package "react-native" asking them to ship the file in .mjs extension or add "type": "module" in their package.json.
As a temporary workaround you can try to inline the package by updating your config:
// vitest.config.js
export default {
test: {
deps: {
inline: [
"react-native"
]
}
}
}
When adding the suggested config the tests break inside React-native instead, as if the modules in fact is not supported.
What is going on here? Is React-Native only published as commonjs modules, while only esm-modules is supported by Vite? Is there a way around it?
Thanks in advance,
M.

How to update the latest workbox version when using Vue CLI

I am using Vue CLI plugin - #vue/cli-plugin-pwa and Google workbox to build a PWA app. I want to use the latest version of the workbox which is 5.1.2 however, when I use the workbox (webpack) plugin to generate service-worker.js file, it only contains the 4.3.1 version as below then I run build script:
importScripts("/precache-manifest.83bfba368ee78b40421bed00a145f5e0.js", "https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
//etc
Is there any way to configure to get the latest version when I bundle, for now, I need to modify manually.
Thanks all
Got the solution (test), use the ReplaceInFileWebpackPlugin plugin, then it worked, simple yet effective.
new ReplaceInFileWebpackPlugin([
{
dir: "dist",
files: ["service-worker.js"],
rules: [
{
search: "releases/4.3.1",
replace: "releases/5.1.2",
},
],
},
]),

Disabling Node.js download in KotlinJS Gradle plugin

The version of Node.js that KotlinJS downloads (as of 1.3.40+) seems not to work in Alpine Linux. The docker image I'm using already has Node baked into it, so there's no reason not to use that one.
However, I'm having trouble figuring out how to set download to false (which should cause KotlinJS to build using the node on the PATH).
The relevant section of my build.gradle looks like this:
kotlin {
target {
useCommonJs()
browser()
}
}
Any help would be appreciated!
Looks like it's pretty similar to #talalUcef's answer:
kotlinNodeJs {
download = false
}
Using the KotlinBrowserJs plugin applies the NodeJsRoot plugin.
The NodeJsRoot plugin applies itself, which causes the NodeJsRootExtension to be included under the name kotlinNodeJs.
Thus, I believe, any of the vars here can be set inside a kotlinNodeJs block.
You can add
node {
download = false
}
on your build.gradle file

webpack-resolve-alias to resolve dependecy's sub-dependency

I'm sort of stuck with one problem and googling it for about three hours brought me nowhere.
Here's the problem. I'm trying to develop my own custom PDF viewer based on PDF.JS lib. Officially it is distributed on npm as pdfjs-dist package. However I need to extend a few classes that are not accessible in pdfjs-dist. So I npm install'ed or yarn add'ed the original repo https://github.com/mozilla/pdf.js.git. This way I have access to classes I need. Inside pdf.js there are core lib that is stored in pdf.js/src/ and a pdf-viewer app that is stored in pdf.js/web/.
Inside that pdf.js/web/ app core lib (pdf.js) is referenced via pdfjs-lib alias that is resolved to pdf.js/src/ during pdf.js inner build process by gulp.
For example pdf.js/web/base_viewer.js:
import { AnnotationLayerBuilder } from './annotation_layer_builder';
import { createPromiseCapability } from 'pdfjs-lib';
import { PDFPageView } from './pdf_page_view';
So now I'm trying to import that pdf.js/web/base_viewer.js in my app that is using latest Webpack 4 (I guess), and this pdfjs-lib sub-dependency is not resolved.
I've tried webpack's resolve-alias mechanism (https://webpack.js.org/configuration/resolve/):
resolve: {
alias: {
'pdfjs-lib': path.resolve(__dirname, './node_modules/pdf.js/src/')
},
}
...but looks like it resolves dependencies only of my own App, but not sub-dependencies of my dependency.
Just in case I'm building Vue 3.0 app using vue-cli and access webpack config this way: https://cli.vuejs.org/guide/webpack.html, but don't think it matters.
Any help from Webpack gurus here?
Thanks.

Intellij+Springboot+Thymeleaf+gradle - autoreload html resources

I am using IntelliJ Ultimate, Spring Boot, and Thymeleaf.
I want to enable auto-reload of HTML without restarting the server and without CTRL-F9.
I have read the following already and I think it should be working, but it's not:
https://github.com/spring-projects/spring-boot/issues/34
IntelliJ 15, SpringBoot devtools livereload not working
Livereload for assets in Intellij using Spring boot
I have done the following steps:
build.gradle snippet
compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: '1.5.2.RELEASE'
compile("org.springframework.boot:spring-boot-devtools")
runtime('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
bootRun {
addResources = true
}
IntelliJ Settings for Compilier:
And Intellij Registry Setting:
My HTML is in main\resources\templates and my application.properties is in \resources\
I then have tried both running and debugging the project but either way, I still have to rebuild (CTRL-F9) between changes to the HTML.
Reading here from snicoll and dsayer this should be possible without the CTRL-F9:
It appears after adding the registry setting :
compilier.automake.allow.when.app.running
You need to restart not only the Springboot server but Intellij too.
It is going now.
If you are still struggling with spring-boot-devtools, I recommend using Gulp to automate templates and resources reload. Following is a little Gulp task that does the magic for me:
var gulp = require('gulp'),
watch = require('gulp-watch');
gulp.task('watch', function () {
return watch('src/main/resources/**/*.*', () => {
gulp.src('src/main/resources/**')
//replace with build/resources/main/ for netBeans
.pipe(gulp.dest('out/production/resources/'));
});
});
gulp.task('default', ['watch']);
I also wrote a short blog post on this topic which includes other methods as well.