Giter Club home page Giter Club logo

shopify-css-import's Introduction

Deprecation warning ⚠️

Instead of these one-off grunt/gulp build tasks, developers are encouraged to check out Slate - a theme scaffolding and command line tool built for developing Shopify themes.

You can continue to use these tasks; however, this repo will not be kept up-to-date with changes in Shopify theme development.


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.

The theme files included in this repo are just for the example. Find the latest version of Timber here.

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 cursedcoder avatar humancopy avatar kennedysgarage avatar tmlayton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shopify-css-import's Issues

Importing from more than one subdir level

Sorry noob question - when my file structure includes more than one level (e.g. css/partials/_file.scss.liquid) that file is not added when gulp is run. The @import url is correct and watch runs correctly but it doesn't update theme.scss.liquid in assets unless the source file is in the top level of /css

So my preferred file structure is this:

/css
  /_partials
      _file.scss.liquid

Rather than:

/css
  _file.scss.liquid

Any help would be greatly appreciated.

npm WARN package.json shopify-css-import@ No repository field.

I got the Gulp section working, but when I try to get the Grunt section working I can't seem to figure it out. Every time I run sudo npm install gulp-cssimport I get the following:

My package.json is exactly from this repo:

{
  "name": "shopify-css-import",
  "devDependencies": {
    "grunt": "~0.4.4",
    "grunt-concurrent": "~0.5.0",
    "grunt-contrib-watch": "~0.6.1",
    "grunt-exec": "~0.4.5",
    "grunt-gulp": "^0.1.0",
    "load-grunt-tasks": "^0.4.0"
  }
}

Not Letting Me "bundle install"

I'm on Step 5 for the Grunt.js part of the installation and I keep getting this error:

Please make sure you have the correct access rights and the repository exists.

and then this error:

Git error: command git clone '[email protected]:Shopify/shopify_theme.git' "/usr/local/rvm/gems/ruby-2.1.1/cache/bundler/git/shopify_theme-3de0c1fc88f476e318398688d2f3d8495e4e0d62" --bare --no-hardlinks in directory /Volumes/Boba/Raph/Sites/shopify has failed.

Any idea what this could be?

Any help appreciated. Thanks!

Don't Compile Files with Underscore Prefix

Is it possible to not have files that are prefixed with an underscore copied across to the assets folder? I thought the _ before the filename tells Sass not to compile it to CSS...?

Error While Watching Theme

I manage to get to Step 6 of adding CSS import to my Shopify theme, and run grunt which begins to watch my directory. Once I make a change to my stylesheet it seems to work and I seem to get a success message.

Done, without errors.
Completed in 0.917s at Sun Jul 20 2014 16:21:17 GMT+0100 (BST) - Waiting...

But then straight after this line, this error is thrown up:

>> /Users/username/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `initialize'
>> : getaddrinfo: nodename nor servname provided, or not known (SocketError)
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `open'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:879:in `block in connect'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:878:in `connect'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:852:in `start'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:1369:in `request'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httparty-0.13.1/lib/httparty/request.rb:93:in `perform'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httparty-0.13.1/lib/httparty.rb:521:in `perform_request'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/httparty-0.13.1/lib/httparty.rb:483:in `put'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/shopify_theme-ca8bca3b91a2/lib/shopify_theme.rb:73:in `send_asset'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/shopify_theme-ca8bca3b91a2/lib/shopify_theme/cli.rb:214:in `block in send_asset'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/shopify_theme-ca8bca3b91a2/lib/shopify_theme/cli.rb:271:in `show_during'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/shopify_theme-ca8bca3b91a2/lib/shopify_theme/cli.rb:213:in `send_asset'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/shopify_theme-ca8bca3b91a2/lib/shopify_theme/cli.rb:135:in `block in watch'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/shopify_theme-ca8bca3b91a2/lib/shopify_theme/cli.rb:168:in `block in watcher'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/filewatcher-0.3.4/lib/filewatcher.rb:30:in `block in watch'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/filewatcher-0.3.4/lib/filewatcher.rb:24:in `loop'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/filewatcher-0.3.4/lib/filewatcher.rb:24:in `watch'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/shopify_theme-ca8bca3b91a2/lib/shopify_theme/cli.rb:167:in `watcher'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/shopify_theme-ca8bca3b91a2/lib/shopify_theme/cli.rb:127:in `watch'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/shopify_theme-ca8bca3b91a2/bin/theme:24:in `<top (required)>'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bin/theme:23:in `load'
    >>  from /Users/username/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bin/theme:23:in `<main>'
Watching current folder: /Users/username/Desktop/shopify-css-import-master
config.yml does not exist!
[16:21:18] Uploading: assets/theme.scss.liquid>> Exited with code: 1.
Warning: Task "exec:theme_watch" failed. Use --force to continue.

Aborted due to warnings.
    Warning:  Use --force to continue.

        Aborted due to warnings.

Any idea what's going on here? Any help is appreciated. Thanks.

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.