Coder Social home page Coder Social logo

marcobarbosa / shopify-css-import Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shopify/shopify-css-import

0.0 2.0 0.0 180 KB

Add CSS import functionality to Shopify theme development with Grunt.js or Gulp.js

Home Page: http://shopify.github.io/shopify-css-import

License: MIT License

Ruby 0.67% JavaScript 1.35% Liquid 97.98%

shopify-css-import's Introduction

Adding CSS @import to theme development

This guide will allow you to define your own folder structure for your stylesheets while building Shopify themes.

Stylesheets can be created and maintained in css/ from your theme's root folder.

In the example css/ folder there is a single theme.scss.liquid file that imports other stylesheets into it. Files starting with an underscore are not added to your assets/ folder.

You can use Grunt or Gulp to achieve the same effect.

Requirements

Basic theme structure

├── assets/
├── layout/
├── snippets/
├── templates/
│
├── // Non-theme files/folders (Theme Gem, Grunt, Gulp, etc.)
├── config.yml
├── css/
├── Gemfile
├── Gruntfile.js
├── package.json
├── gulpfile.js
└── node_modules/

Grunt.js

Navigate to your theme root in Terminal.

1. Install grunt globally
npm install -g grunt-cli

You may have to use sudo for this.

2. Move Gemfile, Gruntfile.js and package.json to your theme's root
3. Install gulp (globally) and gulp-cssimport

We specifically want the Gulp plugin so we have to install Gulp. Everything after this will be handled with Grunt.

npm install -g gulp
npm install gulp-cssimport

You may have to use sudo for this.

4. Install required packages
npm install
5. Run bundle install
bundle install
6. Run grunt
grunt

That's it. Gruntfile.js will run both theme watch to upload new theme files to your store and grunt gulp to concatenate the stylesheets in /css at the same time.

Gulp.js

Navigate to your theme root in Terminal.

1. Install gulp globally
npm install -g gulp

You may have to use sudo for this.

2. Move gulpfile.js file in your theme's root
3. Install required packages
npm install gulp-cssimport
4. Run gulp watch
gulp watch
5. Run Shopify theme gem

Make sure config.yml file is setup properly. Docs here. In a separate Terminal window that is still in your theme's root, run:

theme watch

Output

Once gulp or grunt runs it will create theme.scss.liquid inside your /assets/ folder. To call this file you need to place {{ 'theme.scss.css' | asset_url | stylesheet_tag }} inside your theme.liquid file. Shopify automatically compiles everything on their servers. If for some reason it is not compiling it's probable because there is a random charset somewhere inside your stylesheet.

shopify-css-import's People

Contributors

cshold avatar humancopy avatar marcobarbosa avatar kennedysgarage avatar

Watchers

 avatar James Cloos 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.