Giter Site home page Giter Site logo

Comments (13)

visoft avatar visoft commented on August 16, 2024

Ok, I'm close. The problem had to do with me trying to import foundation which exists in the vendor directory. I guess I have the same problem as #2.

from broccoli-compass.

samselikoff avatar samselikoff commented on August 16, 2024

If you

var pickFiles = require('broccoli-static-compiler');
var vendor = pickFiles('vendor', {srcDir: '/', destDir: '/vendor'});

broccoli will be serving up your entire vendor folder, so @import 'vendor/...' functions will work in sass.

Note that broccoli build would then package up your entire vendor directory, which you don't want to do. So you'll need to do some more work for production.

from broccoli-compass.

g13013 avatar g13013 commented on August 16, 2024

@samselikoff @visoft i've just published the support for multiple value options (v0.0.5) like import-path:

Suppose you have a vendor folder in the root of your project that contains vendor_lib.scss, you can import it in your main scss file:

@import "vendor_lib.scss"
...

and add the import path in the Broccoli task:

 app.styles = function() {
  return compileCompass(this.appAndDependencies(), this.name + '/styles/app.scss', {
    outputStyle: 'expanded',
    importPath: [
      process.cwd() + '/vendor', //relative to the root of your project
      'another_vendor_folder', //merged tree using `broccoli-static-compiler`
      '/absolute/path/to/vendor/folder' //could be outside the project
    ],
    sassDir: this.name + '/styles',
    imagesDir: 'public/images',
    cssDir: '/assets'
  });
};

from broccoli-compass.

samselikoff avatar samselikoff commented on August 16, 2024

@g13013 Having trouble getting it work. The compass command is working, so it's finding the vendor directory, but my imports aren't.

Should it be concatenating everything? My browser is still making requests to each of my vendor imports.

from broccoli-compass.

g13013 avatar g13013 commented on August 16, 2024

please give me an example of your code

from broccoli-compass.

samselikoff avatar samselikoff commented on August 16, 2024

Here's my brocfile: https://gist.github.com/samselikoff/39a23ba58b2f65cd915f

Then in app.scss I have

@import "/vendor/bootstrap/docs/assets/css/bootstrap.css";

ember serve works without errors, but when I load my app in the browser, the vendor css isn't coming through:

image

from broccoli-compass.

g13013 avatar g13013 commented on August 16, 2024

I see that you're importing simple css files using compass, since you are using ember-cliwhy not just import css files like so:

app.import('vendor/bootstrap/docs/assets/css/bootstrap.css');
...
app.import('vendor/bootstrap/docs/assets/js/bootstrap.min.js');
app.import('vendor/mjolnic-bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js');
app.import('vendor/slider/js/bootstrap-slider.js');

if you insist on managing them via compass, you have to copy your vendor folder using broccoli-static-compiler and then your code should work:

var vendor = pickFiles('bower_components', {
      srcDir: '/',
      destDir: '/vendor'
    });
var styles = pickFiles('styles', {
      srcDir: '/',
      destDir: '/styles'
    });
var compiledCss = compileCompass(mergeTrees([vendor, styles]), 'styles/app.scss', {
    outputStyle: 'expanded',
    sassDir: 'styles',
    imagesDir: 'public/images',
    cssDir: 'assets'
  });

and then

@import "vendor/bootstrap/docs/assets/css/bootstrap.css";

from broccoli-compass.

g13013 avatar g13013 commented on August 16, 2024

@samselikoff try this and see what happens https://gist.github.com/g13013/9f1d71f72994199048b8

from broccoli-compass.

g13013 avatar g13013 commented on August 16, 2024

@samselikoff to debug you I advise to use brocolli build "FOLDER" and see it's content, you will understand what happens under the hood :)

from broccoli-compass.

samselikoff avatar samselikoff commented on August 16, 2024

@g13013 That's what I initially tried. By default Ember CLI will take all css files imported using that statement, concat them and output to /assets/vendor.css. But, because I've overwritten app.styles to do the Compass work, that behavior no longer happens.

You can see that functionality here: https://github.com/stefanpenner/ember-cli/blob/master/lib/broccoli/ember-app.js#L271.

When we do app.styles = function() { return compileCompass(..., we no longer get vendor.css so we have to use some other method. That's why I used pickFiles to serve up the vendor directory, and then imported the css in my app.scss file.

from broccoli-compass.

visoft avatar visoft commented on August 16, 2024

This is what worked for me:

var compileCompass = require('broccoli-compass');
app.styles = function() {
  return compileCompass(this.appAndDependencies(), this.name + '/styles/app.scss', {
    outputStyle: 'expanded',
    sassDir: this.name + '/styles',
    imagesDir: 'public/images',
    cssDir: '/assets',
    importPath: [
      process.cwd() + '/vendor/foundation/scss'
    ],
  });
};

Now I'm able to @import foundation from my scss file. The only thing is that instead of the .css being named my-app.css it's simply named app.css now. Is there a way to get the name back to the default?

from broccoli-compass.

g13013 avatar g13013 commented on August 16, 2024

@samselikoff sorry i've never worked with ember-cli :), still no luck ?

@visoft just name your app.scss->'my-app.scss', if you want the file to be dynamically renamed according to the app's name, you can either use an another plugin to rename your scss file or if you don't find you could use my other plugin https://github.com/g13013/broccoli-auto-generated

from broccoli-compass.

samselikoff avatar samselikoff commented on August 16, 2024

@g13013 My initial solution (serving up the whole vendor folder) is working for now. I'll reach out to the Ember CLI team and see if there's a better option out there.

from broccoli-compass.

Related Issues (19)

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.