How to override the "public" directory? - symfony

I've renamed my public directory into www so as the documentation says I've added some line in composer.json file:
"extra": {
"...": "...",
"public-dir": "www"
}
Then I ran composer update.
But it seems not to work.
I have this error :
An exception has been thrown during the rendering of a template ("Asset manifest file "*******/public/build/manifest.json" does not exist.").
So I've added in config/packages/dev/framework.yaml (I'm on dev):
framework:
assets:
json_manifest_path: '%kernel.project_dir%/www/build/manifest.json'
But another error has appeared:
An exception has been thrown during the rendering of a template ("Could not find the entrypoints file from Webpack: the file "*******/public/build/entrypoints.json" does not exist.").
Then I modify webpack.config.js file like this :
Encore
// directory where compiled assets will be stored
.setOutputPath('www/build/')
But the error is still there.
Is there a simple way to rename the public directory?

I've fixed my issue :
In config/packages/webpack_encore.yaml :
webpack_encore:
# The path where Encore is building the assets.
# This should match Encore.setOutputPath() in webpack.config.js.
output_path: '%kernel.project_dir%/www/build'

Related

How to configure postcss in webpack from Symfony with the plugin postcss increasing textsizes?

I want to use the plugin https://github.com/iamfrntdv/postcss-increase-text-sizes to make my fonts larger in the whole css and spit it out into a separate file.
That's why I want to use postCss with webpack in Symfony.
I configure it as follows:
in the webpack.config.js file he writes .enablePostCssLoader()
I create the postcss.config.js file with the following configuration
module.exports = {
from: './web/assets/src/css/custom.css',
output: './output.css',
plugins: [
require("postcss-increase-text-sizes")({
fontSizeMultiplyBy: 1.2,
lineheightMultiplyBy: 1.2,
selectorsBlackList: ["h2"]
}),
],
};
Unfortunately, I do not get anything in the "output", no file named output.css is created after reloading encore with npm run watch or npm run build
Webpack does not report the error that it "does not see" the file even if you type "test test" in the from: directive.
Instead, it throws an error if there is something "wrong" (eg a syntax error) in the postcss.config.js file.

Symfony2 Re-organization config files : parameters.dist.yml issue

I've followed document to re organize files in app/config directory.
Now I have config/common (with config, parameters, parameters.dist, routing, security & services files), and files for each environment in specific directories : app/config/dev and app/config/prod.
But now, when I try to send "composer -n install" to update autoload, I have this error :
[InvalidArgumentException]
The dist file "app/config/parameters.yml.dist" does not exist.
Check your dist-file config or create it.
I know this is a configuration problem, Symfony search my dist file in app/config, how can I redirect it to app/config/common ?
I don't know where is the "dist-file config" written in error.
Thanks!
Found !
It is in composer.json:
under "extra", "incenteev-parameters", I've changed value of "file".

Symfony Webpack/Encore processing unreferenced source images

I am attempting to get Webpack to process and copy all the image files in src folder and output them to the build folder using ‘image-webpack-loader`.
As far as I understand, Webpack will only do this with images referenced in CSS/SASS/LESS or an entry point.
I am working on a Symfony project and have many references in twig templates, which are obviously ignored.
Any idea how I could make this happen without the addition of a build tool or making a duplicate reference file for every image that I include in a project template?
Create a s subdirectory under web root:
Symfony 3:
web/s
Symfony 4 & 5:
public/s
Configure your new subdomain:
Symfony 3: (app/config/config.yml)
framework:
assets:
base_urls:
- '%protocol%://s.%host%'
Symfony 4 & 5: (config/packages/assets.yaml)
framework:
assets:
base_urls:
- '%protocol%://s.%host%'
Note:
%protocol% is either http or https accoring to you environment
%host% is your host, maybe example.com or something.
Configure Webpack (webpack.config.js)
Symfony 3:
var Encore = require('#symfony/webpack-encore');
Encore
// ...
.setOutputPath('./web/s/build/')
.setPublicPath('/build')
.setManifestKeyPrefix('build')
.cleanupOutputBeforeBuild()
// ...
;
module.exports = Encore.getWebpackConfig();
Symfony 4 & 5:
var Encore = require('#symfony/webpack-encore');
Encore
// ...
.setOutputPath('./public/s/build/')
.setPublicPath('/build')
.setManifestKeyPrefix('build')
.cleanupOutputBeforeBuild()
// ...
;
module.exports = Encore.getWebpackConfig();
Put all your images inside /web/s or /public/s according to your Symfony version.
Inside your Twig views, access them like below:
<img src="{{ asset('photo.jpg') }}" alt="Photo"/>
Accept and hit upvote on this cool answer!
In webpack.config.js, you could add .copyFiles() to the Encore object. This will take an object with "from", and "to" keys, with a couple of wildcards.
Here is an example:
.copyFiles({
from: 'src',
to: 'images/[path][name].[ext]'
})

Why is my jar not loading?

I am using the Jsoup jar file in my Coldfusion application. I was originally storing it in a local lib folder, but for security purposes we decided to store it in the cfroot lib folder. I uploaded the jar to the /lib folder in root, and added this code to Application.cfc:
this.javaSettings = {
loadPaths: [
"./lib/"
],
loadColdFusionClassPath: true
};
However, my code (that was working before) now generates the following error:
ERROR
Object Instantiation Exception.
Class not found: org.jsoup.JsoupObject Instantiation Exception.
...
It seems the code is not finding/loading the jar file. How can I point the code towards the Jsoup jar file stored in root?
Try backslash instead of forward-slash,
this.javaSettings = {
loadPaths: [
".\lib\"
],
loadColdFusionClassPath: true
};

grails : deployement error on tomcat ( resources not found )

I have a grails application.
I make a war with 'grails war' then I deploy it on Tomcat.
I have the following errors :
ERROR resources.ResourceMeta: Resource not found: /js/application.js
ERROR resources.ResourceMeta: Resource not found: /js/bootstrap.min.js
ERROR resources.ResourceMeta: Resource not found: /css/bootstrap.min.css
I unzip my war file and I have the following :
fjLearning.war :
css/
main__v1385391634036.css
main__v1385391634036.gz.css
..
js/
jquery-1.8.3.min__v1385391634036.js
...
...
I tried to access to the full path of the resource :
mysite.com/fjLearning/static/js/application__v1385389616024.js
, and it's OK.
But, if I try to access to mysite.com/fjLearning/static/js/application.js, it doesn't work.
To check that the problem comes from files names, I change manually all of them.
Then, I deploy again my war file and it works !
So do you know where does theses files names come from ?
PS :
I suspect ui-performance plugin so I will check if I use it correctly ...
My configuration :
This project is on GitHub : https://github.com/drieu/fjLearning
Grails : 2.3.3
Tomcat : apache-tomcat-7.0.47
Comment : I can run this application with grail run-app without problem.
Buildconfig.groovy :
plugins {
runtime ":hibernate:3.6.10.4"
runtime ":jquery:1.8.3"
runtime ":resources:1.2"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.5"
//build ":tomcat:$grailsVersion"
build ":tomcat:7.0.47"
runtime ":database-migration:1.3.2"
compile ':cache:1.0.1'
}
Config.groovy :
modules = {
application {
resource url:'js/application.js'
}
bootstrap {
resource url:'js/bootstrap.min.js'
resource url:'css/bootstrap.min.css'
resource url:'css/main.css'
dependsOn 'jquery'
}
}

Resources