Chapters
21 Chapters
|
2:10:39
|
Login to bookmark this video
-
Course Code
Login or register to download the code!Compatible PHP versions: ^7.1.3
Login or register to download the code!Compatible PHP versions: ^7.1.3
-
This Video
Login or register to download the video!
Login or register to download the video!
-
Subtitles
Login or register to download the subtitles!
Login or register to download the subtitles!
-
Course Script
Login or register to download the script!
Login or register to download the script!
14.
Auto-Provide jQuery for Mischievous Packages
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
This tutorial works great with Symfony5!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"aws/aws-sdk-php": "^3.87", // 3.91.4
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/annotations": "^1.0", // 1.10.1
"doctrine/doctrine-bundle": "^1.6.10", // 1.10.2
"doctrine/doctrine-migrations-bundle": "^1.3|^2.0", // v2.0.0
"doctrine/orm": "^2.5.11", // v2.7.2
"knplabs/knp-markdown-bundle": "^1.7", // 1.7.1
"knplabs/knp-paginator-bundle": "^2.7", // v2.8.0
"knplabs/knp-time-bundle": "^1.8", // 1.9.0
"league/flysystem-aws-s3-v3": "^1.0", // 1.0.22
"league/flysystem-cached-adapter": "^1.0", // 1.0.9
"liip/imagine-bundle": "^2.1", // 2.1.0
"nexylan/slack-bundle": "^2.0,<2.2.0", // v2.1.0
"oneup/flysystem-bundle": "^3.0", // 3.0.3
"php-http/guzzle6-adapter": "^1.1", // v1.1.1
"phpdocumentor/reflection-docblock": "^3.0|^4.0", // 4.3.0
"sensio/framework-extra-bundle": "^5.1", // v5.3.1
"stof/doctrine-extensions-bundle": "^1.3", // v1.3.0
"symfony/asset": "^4.0", // v4.2.5
"symfony/console": "^4.0", // v4.2.5
"symfony/flex": "^1.9", // v1.21.6
"symfony/form": "^4.0", // v4.2.5
"symfony/framework-bundle": "^4.0", // v4.2.5
"symfony/property-access": "4.2.*", // v4.2.5
"symfony/property-info": "4.2.*", // v4.2.5
"symfony/security-bundle": "^4.0", // v4.2.5
"symfony/serializer": "4.2.*", // v4.2.5
"symfony/twig-bundle": "^4.0", // v4.2.5
"symfony/validator": "^4.0", // v4.2.5
"symfony/web-server-bundle": "^4.0", // v4.2.5
"symfony/webpack-encore-bundle": "^1.4", // v1.5.0
"symfony/yaml": "^4.0", // v4.2.5
"twig/extensions": "^1.5" // v1.5.4
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0", // 3.1.0
"easycorp/easy-log-handler": "^1.0.2", // v1.0.7
"fzaninotto/faker": "^1.7", // v1.8.0
"symfony/debug-bundle": "^3.3|^4.0", // v4.2.5
"symfony/dotenv": "^4.0", // v4.2.5
"symfony/maker-bundle": "^1.0", // v1.11.5
"symfony/monolog-bundle": "^3.0", // v3.3.1
"symfony/phpunit-bridge": "^3.3|^4.0", // v4.2.5
"symfony/stopwatch": "4.2.*", // v4.2.5
"symfony/var-dumper": "^3.3|^4.0", // v4.2.5
"symfony/web-profiler-bundle": "4.2.*" // v4.2.5
}
}
What JavaScript libraries does this tutorial use?
// package.json
{
"devDependencies": {
"@symfony/webpack-encore": "^0.27.0", // 0.27.0
"autocomplete.js": "^0.36.0",
"autoprefixer": "^9.5.1", // 9.5.1
"bootstrap": "^4.3.1", // 4.3.1
"core-js": "^3.0.0", // 3.0.1
"dropzone": "^5.5.1", // 5.5.1
"font-awesome": "^4.7.0", // 4.7.0
"jquery": "^3.4.0", // 3.4.0
"popper.js": "^1.15.0",
"postcss-loader": "^3.0.0", // 3.0.0
"sass": "^1.29.0", // 1.29.0
"sass-loader": "^7.0.1", // 7.3.1
"sortablejs": "^1.8.4", // 1.8.4
"webpack-notifier": "^1.6.0" // 1.7.0
}
}
15 Comments
Hey there
Could you tell me more about your problem? I don't understand what went wrong.
In my opinion, Webpack Encore is a great Symfony component, it simplifies a lot working with Webpack
Cheers!
just want to achieve jquery / java script - available on webpage. Not somewhere in mystery Encore cloud.
webpack.config.js1) not working:
new webpack.ProvidePlugin({<br />$: 'jquery',<br />jQuery: 'jquery',<br />});2) not working
// uncomment if you're having problems with a jQuery plugin<br />.autoProvidejQuery()app.js
NOT working
import './styles/app.css';
import 'bootstrap';
console.log('whatewer);
import '@popperjs/core';
======================
NOT working
import $ from 'jquery';
========================
NOT working
const $ = require('jquery') ;
let $ = require('jquery');
import 'webpack-jquery-ui';
global.$ = global.jquery = $;
....
each time I render the
builddir, clean cachetwig has propper import `
{{ encore_entry_link_tags('app') }}
`{{ encore_entry_script_tags('app') }}
Encore just dont want to be friend. I dont understand the idea of this tool. Everything it does can be achieved SIMPLER.
I got your point, jQuery and Webpack may have problems but it's because there are a few jQuery plugins badly written. You can get more info about it here https://github.com/symfony/webpack-encore/issues/244
A quick workaround would be to add these lines to your
webpack.config.jsfileAnyway, Symfony has a component's architecture, it does not force about anything, you can add or remove any Symfony component as you please. If Webpack Encore does not fit your needs, you can remove it and use something else instead
Cheers!
Hi diego, firstly, thank You for your time,
we have progress but not quite.
I have removed nodeJs.14, installed nodeJs 18. - that was main reason for problems.
your workaround is great. Just need to defeat one more yelling information from parser about the proper path
found at <a href="https://webpack.js.org/configuration/output/#outputpath">webpack path managing</a>
`
module.exports = {
};
const config = Encore.getWebpackConfig();
config.resolve.alias.jquery = path.join(__dirname, 'node_modules/jquery/dist/jquery');
`
thx, Cheers!
Hello. I have a problem.
In algoria-autocomplete.js file i was trying to import like you:
import 'autocomplete.js/dist/autocomplete.jquery';
But in new version algoria autocomplete there is no such directory there :/
I tried several options but failed. Could you help me? :)
problem solved, I installed another command "yarn add @algolia/autocomplete-js " instead of "Yarn add autocomplete.js –dev ".
Thanks for your greate courses :)
Hey Lechu85,
Thank you for sharing your solution with others!
P.S. though, you may still want to add "--dev" option to that command as well to install it as a dev dependency :)
Cheers!
Can you tell why --dev must be? After all, autocomplete is also used in production mode :)
Hey Lechu85,
I bet it's explained somewhere in this course ;) But in short, it's not about "must be", but it's just a good practice. That's because all your NodeJS dependencies you install with Yarn are dev-type and nothing is available to the user. Then, the intermediate layer that is Webpack Encore in this case is handle this and compile the final version of those dependencies into the public/build/ folder which in turn is available for users. So, technically, all your JS deps are dev deps and Webpack Encore processes them and compile for users.
I hope it's clearer for you now :)
Cheers!
Thanks for your answer. I understand well.
Thank you! Does
.autoProvidejQuery()use Webpack'sProvidePluginunder the hood?Hey Anton,
Yes, it should use Webpack's ProvidePlugin behind the scene: https://webpack.js.org/plug... - it's just Encore shortcut for jQuery.
Cheers!
Thanks Victor!
Your explanation to fix the agolia-autocomplete problem saves my week. Thank you!
Hey Holger,
Thank you for your feedback! We are really happy to hear this from our users :) And that's why wer're doing screencasts! We want to help our users to understand things better, faster, and save them some time! :)
Cheers!
"Houston: no signs of life"
Start the conversation!