sass-eyeglass / ember-cli-eyeglass Goto Github PK
View Code? Open in Web Editor NEWUse eyeglass and node-sass to compile Sass files in your ember project.
Use eyeglass and node-sass to compile Sass files in your ember project.
I have an existing addon, @fastly/style-guide
. I'm trying to extract eyeglass-aware pieces out of it. In this case, I'm trying to pull out @fastly/fui-color
.
// @fastly/fui-color/index.scss
:root {
--purple: rebeccapurple;
}
// @fastly/style-guide/app/styles/fastly/variables/_colors.scss
@import "@fastly/fui-color";
// @fastly/style-guide/tests/dummy/app/styles/app.scss
@import "fastly/variables/colors";
body { color: var(--purple); }
When I try to build this, it fails:
- name: Error
- nodeAnnotation: EyeglassCompiler
- nodeName: EyeglassCompiler
- originalErrorMessage: Error: Could not import ~@fastly/fui-color from any of the following locations:
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color.scss
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color.sass
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color.css
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/_fui-color.scss
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/_fui-color.sass
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/_fui-color.css
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color/index.scss
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color/index.sass
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color/index.css
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color/_index.scss
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color/_index.sass
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color/_index.css
at /Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/_all.scss:11:9
- stack: Error: Error: Could not import ~@fastly/fui-color from any of the following locations:
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color.scss
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color.sass
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color.css
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/_fui-color.scss
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/_fui-color.sass
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/_fui-color.css
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color/index.scss
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color/index.sass
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color/index.css
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color/_index.scss
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color/_index.sass
/Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/~@fastly/fui-color/_index.css
at /Users/jamesrosen/Code/style-guide/tmp/eyeglass_compiler-input_base_path-CRY4bAvX.tmp/app/styles/fastly/variables/_all.scss:11:9
at options.error (/Users/jamesrosen/Code/style-guide/node_modules/node-sass/lib/index.js:286:26)
Some hypotheses:
@import
with namespaced packages doesn't workember-cli-build.js
or another configuration file@fastly/fui-color
as "eyeglass-aware" (though it doesn't contain any Sass JavaScript)I'm using [email protected]
.
Steps to repro:
git clone [email protected]:sass-eyeglass/ember-cli-eyeglass.git
cd ember-cli-eyeglass && yarn
ember s
yellow
to blue
in tests/dummy/lib/eager/addon/styles/addon.scss
I also confirmed that the templates do update and appears to only be the styles.
I have been trying to set up ember-cli-eyeglass
for my open source app Bookmeister, switching from Ruby Sass.
I guess it's not too surprising that it doesn't compile immediately without errors, but the problem I'm struggling with is that all errors seem to be squelched somewhere inside Broccoli.
So if I make a really simple app.scss
file, like this:
body {
background-color: chartreuse;
}
…everything works just fine. A bookmeister.css
file is created with those contents.
The problem occurs when I try to use my previous setup, as before with partials and Sass libraries, ember build
just stops generating a bookmeister.css
file at all.
I have tried digging a bit into this library, and broccoli-eyeglass beneath it, but I have not been able to figure out which of the two causes the errors to be silenced, so I'm filing this here. I'll try to investigate further on my own, but if anyone had a few pointers on where I should look, I would be grateful.
There was an app that had to set httpRoot
explicitly in the eyeglass config instead of it being inferred by the ember config.
I feel discriminated. :)
My assets are hosted on a separate server from my Ember application, so I need to customize the httpRoot
option, which defaults to my Ember application's URL.
// config/environment.js
module.exports = function(environment) {
var ENV = {
eyeglass: {
// It would be nice if I could set the `httpRoot` like this:
httpRoot: 'https://cdn.com/',
// I've gotten it to work using the `optionsGenerator` like this,
// but seems a bit messy.
optionsGenerator(sassFile, cssFile, options, callback) {
options.httpRoot = 'https://cdn.com/';
callback(cssFile, options);
}
}
};
};
I'd be happy to work on a PR, but I'm confused when/where the httpRoot
is actually being set.
addon/styles/<addon_name>.scss
doesn't get included in the build. To parallel default ember-cli functionality, which includes addon/styles/<addon_name>.css
in the build, it should.
This is probably related to #9.
The cssDir option is not passed through to broccoli-eyeglass. I think this should be documented on the main page as it's not immediately obvious.
There's a number of issues involving assets and how they work in eyeglass with ember apps, especially with ember engines, and especially when those engines are in lazy mode. We're going to change the way assets are configured by default for ember applications so that asset-url()
works better and more predictably for ember applications.
Current invocations of asset-url()
will continue to work unmodified, providing backwards compatibility to existing apps. This change must be non-breaking and introduce no deprecations. The only risk for apps is if there is a url to an asset installed by eyeglass during compilation, where that URL has been hard-coded instead of referencing the asset according to the url returned by asset-url()
or asset-uri()
.
asset-url()
.Assets delivered from an eyeglass module should be installed to a canonical location. Because eyeglass modules are guaranteed to resolve to a single instance, the assets are guaranteed to be the same across multiple transitive dependencies even if they resolve from npm to different versions.
Assets will be installed according to the source location.
asset-url()
function. Baring intervention from a custom installer, Eyeglass will not install these assets, but it will return a url that conforms to the location that ember will ultimately install the public asset.assets/eyeglass-modules/<module-name>/<path-to-asset>
. ember-cli-eyeglass
will accept a new configuration parameter that allows the directory of eyeglass module assets to be specified but it will default to assets/eyeglass-modules
. The behavior of how conflicts between installed assets and assets in the public directory is handled will be documented, but it is decided by whatever ember-cli does naturally.Note: there is currently an override behavior in eyeglass, but it's really not clear how it interacts with ember-cli's public directory semantics We need to decide what the right semantics are and make sure it's clearly documented and implemented accordingly.
Here's how I think it should work:
Assets in the public directory of the app can override the asset normally delivered by an engine, addon, or module by having an asset in a directory that overrides that of the same source url. For example, if an engine or addon named my-swanky-addon
has an asset at <addon-root>/public/assets/icons/swanky.gif
, then that can be accessed via asset-url("my-swanky-addon/icons/swanky.gif")
. If the app puts a different image in the public directory at <app-root>/public/assets/my-swanky-addon/icons/swanky.gif
, this will be the asset resolved regardless of whether the app or addon is the one creating the url.
If the asset is referenced as asset-url("icons/swanky.gif")
from either the addon or the app, it will still work, but the override location will then be <app-root>/public/assets/icons/swanky.gif
and I need to know whether this file would be overwritten by the addon or if the app wins according to ember-cli semantics.
I think the decisions for how to find files in the public directory are based on a merged app tree, not the application source. This means that addons can deliver assets to the app's public directory that have the effect of overriding the assets of other eyeglass addons or modules. This allows for overriding of assets by an addon that nests another addon or is installed along side the main application.
Asset overriding must work the same for both lazy and eager engines, even though lazy engines have a different broccoli tree.
There's still some unanswered aspects but I want to make sure this core design is solid.
After making changes to dummy/lib/lazy/addon/styles/addon.scss
and running npm run build
, changes are not reflected in dist/engines-dist/lazy/assets/engine.css
. Only after rm -rf node_modules
, yarn
, npm run build
are changes reflected in dist/engines-dist/lazy/assets/engine.css
.
Steps to repro:
git clone [email protected]:sass-eyeglass/ember-cli-eyeglass.git
cd ember-cli-eyeglass
yarn
npm run build
cat dist/engines-dist/lazy/assets/engine.css
dummy/lib/lazy/addon/styles/addon.scss
npm run build
cat dist/engines-dist/lazy/assets/engine.css
I was using ember-cli-sass and this works well however I'm interested in using Eyeglass.
I removed ember-cli-sass and installed ember-cli-eyeglass
When I attempt to build with ember-cli-eyeglass I get the following error:
Build failed.
The Broccoli Plugin: [EyeglassCompiler: EyeglassCompiler: leftoverbits] failed with:
Error: File to read not found or unreadable: Z:/EmberJS/myproj/tmp/eyeglass_compiler-input_base_path-W0yfYjmr.tmp/Z:/EmberJS/myproj
/tmp/eyeglass_compiler-input_base_path-W0yfYjmr.tmp/app/styles/app.scss
at undefined:undefined:undefined
I'm running on Windows 10 x64.
Problem:
We currently load configuration for the app/addon/engine we're building styles for from its environment.js file. Config values defined in that file our sent to the browser at runtime, so it'd be better if we instead have consumers define them in a place that isn't sent to the browser, since there's no need to have Eyeglass config values available at runtime.
Proposed Solution:
We should start looking for eyeglass configs on the config values coming from an app's ember-cli-build.js and an addon/engine's index.js. Values from these sources are only used at build-time and aren't sent to the browser. When a consumer defines both, we should prefer the build-time only config and warn them that it is being used instead of the one from environment.js. When a consumer defines eyeglass configs in environment.js, we should warn them that it is deprecated and they should move the configs to the build-time sources.
Details:
For an app, consumers can place an eyeglass
key on the options
passed to new EmberApp()
. We should update our README to reflect this as the appropriate place for app configs.
For an addon/engine, consumers can place an eyeglass
key on this.options
in the init()
method defined in the addon/engine's index.js. For an example, see this from ember-computed-decorators: https://github.com/rwjblue/ember-computed-decorators/#setup-with-addon
We should update our README to reflect this as the appropriate place for addon/engine configs.
In ember-cli-eyeglass, we can then access the config using this.parent.options
or this.app.options
. Here's an example of how ember-cli-babel does this: https://github.com/babel/ember-cli-babel/blob/master/index.js#L95-L97
Credits:
Thanks to @rwjblue for guiding me through the possible solution and for being a point-of-contact for Ember CLI-related details.
// path/to/app/ember-cli-build.js
const app = new EmberApp(defaults, {
options: {
eyeglass: { /* configuration */ }
}
});
should be:
// path/to/app/ember-cli-build.js
const app = new EmberApp(defaults, {
eyeglass: { /* configuration */ }
});
i can add the .travisyml stuff, but I can't enable travis. Likely a good idea to get CI on this.
When including ember-cli-eyeglass for sass compiling within an addon or engine, Eyeglass only looks inside the app directory, not the addon directory (app should be empty), and complains. Root issue is really with eyeglass not able to compile an addon, since it only looks in node_modules/ember-cli-eyeglass/index.js
, looks for consuming app's env, and then dies:
Example error output:
⠋ BuildingCannot read property 'env' of undefined
TypeError: Cannot read property 'env' of undefined
at Object.registry.add.toTree (/Users/cklimkow/workspace/testmanager-engine_trunk/node_modules/ember-cli-eyeglass/index.js:34:59)
Current hack/work-around:
//package.json
"eyeglass": {
"exports": "eyeglass-exports.js",
"name": "addon-name",
"needs": "^0.8.2"
},
"keywords": [
"ember-addon",
"eyeglass-module"
]
...and then we create an eyeglass-exports.js
file in the root:
//eyeglass-exports.js
/* jshint node:true */
var path = require('path');
module.exports = function(/* eyeglass, sass */) {
return {
sassDir: path.join(__dirname, 'addon', 'styles')
};
};
Consuming Ember app must then @import "addon-name";
in its app.scss
.
/cc @cklimkowsky @nathanhammond
rather it should be in the build config. Otherwise we ship our configuration to the browser, which is wasteful.
Hi there,
Just tried to update to ember-cli-eyeglass 1.0.1, and broccoli builds now fail starting at Object.registry.add.toTree
in node_modules/ember-cli-eyeglass/index.js
with a TypeError ("undefined is not a function.")
I can provide the full stacktrace if you need it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.