Last active
August 24, 2020 15:56
-
-
Save shedali/3f07e0e2f3b5d597739b450ec6330726 to your computer and use it in GitHub Desktop.
svelte compile for php include
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
require('svelte/register'); | |
const Component = require('./Widget.html').default; | |
const { head, html, css } = Component.render({ | |
answer: "cms-string-content"// pass in cms values as props | |
}); | |
fs.writeFileSync("output/styles.css", css.code); | |
//write out for content editor | |
fs.writeFileSync("output/index.html", html) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo "hello world" ?> | |
<style> | |
<?php include 'output/styles.css';?> | |
</style> | |
<?php include 'output/index.html';?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "svelte-compile", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"build": "node compile; echo see output dir", | |
"serve":"php -S 127.0.0.1:8080" | |
}, | |
"keywords": [], | |
"author": "Franz", | |
"license": "ISC", | |
"devDependencies": { | |
"svelte": "^3.24.1" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export let answer="" | |
</script> | |
<style> | |
.encapsulated-style-here { | |
color: red; | |
} | |
</style> | |
<div class="encapsulated-style-here"> | |
{answer} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment