File tree 11 files changed +76
-19
lines changed
11 files changed +76
-19
lines changed Original file line number Diff line number Diff line change 1
- import "./app.scss" ;
2
-
3
1
// we need to import all assets to provide manifest for symfony asset tag
4
2
import . meta. glob ( [
5
3
'./images/**'
6
4
] ) ;
7
5
8
- import "./components/test-component.svelte"
9
- import "./components/asset-component.svelte"
10
- import "./components/modal-component.svelte"
11
-
12
-
13
6
console . log ( "Init js from vite" ) ;
Original file line number Diff line number Diff line change 3
3
<script >
4
4
import svg from " ../images/vector/github.svg"
5
5
import children1 from " ../images/children/1.jpg"
6
- export let customprop1 = null ;
7
- export let customprop2 = null ;
8
6
</script >
9
7
10
8
<div >
13
11
</div >
14
12
15
13
<style lang =" scss" >
16
- p {color : chocolate }
17
- h1 {color : cornflowerblue }
14
+
18
15
</style >
Original file line number Diff line number Diff line change
1
+ import "../components/test-component.svelte"
2
+ import "../components/asset-component.svelte"
3
+ import "../components/modal-component.svelte"
4
+
5
+ // we can make separate entry point for each web component, or combine them in an entry point
6
+ console . log ( "web components imported" ) ;
Original file line number Diff line number Diff line change
1
+ @media (min-width : 700px ) {
2
+ p {
3
+ color : chocolate ;
4
+ }
5
+ .hide {
6
+ display : none ;
7
+ }
8
+ }
9
+
Original file line number Diff line number Diff line change 1
1
body {
2
- background-color : #eeeeee ;
2
+ background-color : #242121 ;
3
3
p {
4
4
color : cyan ;
5
5
}
Original file line number Diff line number Diff line change
1
+ @media print {
2
+ h1 {
3
+ color : black ;
4
+ background-color : white ;
5
+ }
6
+ }
Original file line number Diff line number Diff line change 4
4
defaults :
5
5
template : ' index.html.twig'
6
6
statusCode : 200
7
+ webcomponents :
8
+ path : /webcomponents
9
+ controller : Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction
10
+ defaults :
11
+ template : /webcomponents/index.html.twig
Original file line number Diff line number Diff line change 6
6
<link rel =" icon" href =" data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text></svg>" >
7
7
{% block stylesheets %}
8
8
{{ vite_entry_link_tags(' app' ) }}
9
+ {{ vite_entry_link_tags(' mobileStyles' ) }}
10
+ {{ vite_entry_link_tags(' desktopStyles' , {
11
+ attr : {
12
+ media : " screen and (min-width: 700px)"
13
+ }
14
+ })}}
15
+ {{ vite_entry_link_tags(' printStyles' , {
16
+ attr : {
17
+ media : " print"
18
+ }
19
+ })}}
20
+
9
21
{% endblock %}
10
22
11
23
{% block javascripts %}
12
24
{{ vite_entry_script_tags(' app' ) }}
25
+ {{ vite_entry_script_tags(' mobileStyles' ) }}
26
+ {{ vite_entry_script_tags(' desktopStyles' ) }}
27
+ {{ vite_entry_script_tags(' printStyles' ) }}
13
28
{% endblock %}
14
29
</head >
15
30
<body >
Original file line number Diff line number Diff line change 1
1
{% extends " base.html.twig" %}
2
+
2
3
{% block body %}
3
4
<p >base</p >
4
- <test -component customprop 1=" 1" customprop 2=" true" ></test -component >
5
- <p >we can use static asset import in web component</p >
6
- <asset -component ></asset -component >
7
- <p >We also can use images from vite with standart asset tag</p >
5
+ <a href =" /webcomponents" >webcomponents</a >
6
+ <p >We also can use images from vite with standard asset tag</p >
8
7
<img src =" {{ asset(' assets/images/vector/github.svg' ) }}" />
9
- <p >slots</p >
10
- <modal -component >some modal text passed inside svelte component</modal -component >
8
+ <p class =" hide" >this text visible only in px<700 </p >
11
9
{% endblock %}
Original file line number Diff line number Diff line change
1
+ {% extends " base.html.twig" %}
2
+
3
+ {% block stylesheets %}
4
+ {{ parent () }}
5
+ {{ vite_entry_link_tags(' webcomponents' ) }}
6
+ {% endblock %}
7
+
8
+ {% block javascripts %}
9
+ {{ parent () }}
10
+ {{ vite_entry_script_tags(' webcomponents' ) }}
11
+ {% endblock %}
12
+
13
+ {% block body %}
14
+ <p >base</p >
15
+ <a href =" /" >no web components</a >
16
+ <test -component customprop 1=" 1" customprop 2=" true" ></test -component >
17
+ <p >slots</p >
18
+ <modal -component >some modal text passed inside svelte component</modal -component >
19
+ <p >we can use static asset import in web component</p >
20
+ <asset -component ></asset -component >
21
+ <p >We also can use images from vite with standart asset tag</p >
22
+ <img src =" {{ asset(' assets/images/vector/github.svg' ) }}" />
23
+
24
+ {% endblock %}
Original file line number Diff line number Diff line change @@ -24,7 +24,11 @@ export default defineConfig({
24
24
build : {
25
25
rollupOptions : {
26
26
input : {
27
- app : "./assets/app.js"
27
+ app : "./assets/app.js" ,
28
+ mobileStyles : "./assets/scss/mobile.scss" ,
29
+ desktopStyles : "./assets/scss/desktop.scss" ,
30
+ printStyles : "./assets/scss/print.scss" ,
31
+ webcomponents : "./assets/entrypoints/webcomponents.js" ,
28
32
} ,
29
33
}
30
34
} ,
You can’t perform that action at this time.
0 commit comments