Git Product home page Git Product logo

sapper-codyframe's Introduction

Sapper + Codyframe

This project is a template for Sapper if you want to work with CodyFrame framework (from Cody House) and you want to compile the SASS files and useing it directly with Rollup


Note: You can use this template directly or you can follow the instructions below


First things

After getting the template of sapper for Rollup by:

npx degit "sveltejs/sapper-template#rollup" my-app

You have to install the ordinary dependencies by npm install and try to run it by : npm run dev & open http://localhost:3000

Issues could happen

If you have this issue UnhandledPromiseRejectionWarning: Error: No valid exports main found for /..node_modules/@rollup/pluginutils just remove the rollup package from npm and reinstall a new version of it like "2.13.0".

Also if you don't have Polka install it by npm install --save polka

You can use express js instead of Polka, learn how to do that from this Youtube video

Dependencies for SASS compiler

  • svelte-preprocess
  • autoprefixer
  • node-sass

npm install -D node-sass autoprefixer svelte-preprocess

or

yarn add -D node-sass autoprefixer svelte-preprocess

Rollup Configurations

Inside the rollup.config.js file, add these lines outside of export default to be accessible globally:

// for sass (codyframe)
import sveltePreprocess from 'svelte-preprocess';
const preprocess = sveltePreprocess({
  scss: {
    includePaths: ['src'],
  },
  postcss: {
    plugins: [require('autoprefixer')],
  },
});

Also add these lines in both Client and Server sections inside of svelte({...}):

svelte({
  ...
  preprocess // Add this line
  ...
}),

Get the CodyFrame

Clone the official project from GitHub: Here

We just want the assets folder, So copy it inside codyframe folder in your src folder.

We want the style.scss and util.js later.

Sapper Tepmlate File

Add these lines in the template.html file inside src folder:

  • in header section
<!--  cody framework	 -->
<script>document.getElementsByTagName("html")[0].className += " js";</script>

Sapper Layout File

In _layout.svelte file inside of routes folder, Add these lines directly after<script>...</script> lines:

<!-- candy framework Scss - Global -->
<style lang="scss" global>
@import "./codyframe/assets/css/style.scss"
</style>

Also add important javascript libraries like this:

<!--  cody framework - js library -->
<svelte:head>
    <script defer src="codyframe/util.js"></script>
</svelte:head>

Last Step!

Don't forget to add util.js inside of codyframe folder in static folder of the project

Testing!

In your index.svelte route, Add any code to test codyframe components, Like this Button:

 <div><button class="btn btn--primary btn--md">Zaki Button!</button></div>

Enjoy!


Big Thanks to Sean Schertell, He wrote a great article about Sapper & Sass ๐Ÿ˜Š

Also Thanks to @HamzaPlus for the IDEA ๐Ÿ˜Š

My twitter Zakaria Chahboun

sapper-codyframe's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.