gpoitch / ember-cli-inline-content Goto Github PK
View Code? Open in Web Editor NEWAn ember-cli add-on to render inline scripts, styles, or any content directly into your index.html file
License: MIT License
An ember-cli add-on to render inline scripts, styles, or any content directly into your index.html file
License: MIT License
We're trying to deploy to Heroku and for some reason we keep getting this error. Everything builds into dist
fine locally and runs locally.
BuildingBuilding.Build failed.
Cannot set property 'fromString' of undefined
TypeError: Cannot set property 'fromString' of undefined
We've tried clearing the Heroku cache but still nothing.
The only thing we're using inlineContent
for is this:
var app = new EmberApp({
inlineContent: {
'analytics' : {
file: './analytics.js',
postProcess: function(content) {
return content.replace(/\{\{SEGMENT_KEY\}\}/g, config.segmentKey);
}
}
}
});
it was working fine before we upgraded to ember-cli 0.2.2
The full stacktrace given to us by Heroku is as follows:
TypeError: Cannot set property 'fromString' of undefined
at InlineContentRenderer.renderScript (/tmp/build_cf0dd66cf1a6dce9411922de861dbcca/node_modules/ember-cli-inline-content/index.js:81:30)
at InlineContentRenderer.contentFor (/tmp/build_cf0dd66cf1a6dce9411922de861dbcca/node_modules/ember-cli-inline-content/index.js:41:23)
at /tmp/build_cf0dd66cf1a6dce9411922de861dbcca/node_modules/ember-cli/lib/broccoli/ember-app.js:1249:49
at Array.reduce (native)
at EmberApp.contentFor (/tmp/build_cf0dd66cf1a6dce9411922de861dbcca/node_modules/ember-cli/lib/broccoli/ember-app.js:1248:33)
at replacement (/tmp/build_cf0dd66cf1a6dce9411922de861dbcca/node_modules/ember-cli/lib/broccoli/broccoli-config-replace.js:68:36)
at String.replace (native)
at CustomReplace.processFile (/tmp/build_cf0dd66cf1a6dce9411922de861dbcca/node_modules/ember-cli/lib/broccoli/broccoli-config-replace.js:72:25)
at CustomReplace.process (/tmp/build_cf0dd66cf1a6dce9411922de861dbcca/node_modules/ember-cli/lib/broccoli/broccoli-config-replace.js:52:10)
at lib$rsvp$$internal$$tryCatch (/tmp/build_cf0dd66cf1a6dce9411922de861dbcca/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:489:16)
Thanks for taking the time to look at this!
Olark for eg uses a data-cfasync attribute on the script tag for CloudFlare configuration
For example, I have router.js:
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('user', function() {
this.route('register');
this.route('login');
});
});
export default Router;
Then I want custom attributes.
I did in app/index.html like that:
In ember-cli-build.js I did something like:
inlineContent: {
'body_styles': {
content: "skin-blue sidebar-mini"
}
}
But I want to vary body_styles replacement string depend of application route. For example, for route user/register I need:
'body_styles': {
content: "register_page"
}
etc, etc. How can I do that? Thanks.
Link over from ember-cli/ember-cli#2244
I think of a syntax like this:
inlineContent: {
'google-analytics' : {'ext/google-analytics.js', env: ['test', 'prod']},
'foo' : {'ext/google-analytics.js', env: ['-prod']}, // exclude on prod
'bar' : {'ext/google-analytics.js', env: ['all']}, // same as next line
'fast-style' : 'ext/red.css' // don't break old syntax
}
Just reporting this, great addon btw :)
version: 0.1.1
Cannot find module 'uglify-js'
Error: Cannot find module 'uglify-js'
at Function.Module._resolveFilename (module.js:331:15)
at Function.Module._load (module.js:273:25)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at Object. (/var/www/marcemira/node_modules/ember-cli-inline-content/index.js:3:16)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
at Function.Module._load (module.js:305:12)
at Module.require (module.js:357:17)
at require (module.js:373:17)
Moved from #3
Would love being able to add scripts with a src, where the script isn't processed, without having to write HTML markup, with the ability to add query params.
inlineContent: {
'gmaps-api': {
url: '//maps.googleapis.com/maps/api/js',
params: {
v: '3.exp',
libraries: ['drawing', 'geometry'].join(',')
}
}
}
Then you can change the version to stable in production, and add a clientId or an apikey.
Also supporting 'gmaps-api': '[http:|https:|etc]//maps.googleapis.com/maps/api/js'
where a check is performed if it's a path or a url, if url set as src
, otherwise put inside.
The assets now have paths like:
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/website.css">
How can I reference these with this addon to inline them?
I'm struggling to access configuration set in environment.js
from the Brocfile.js
.
I'm not sure if there's a way to do it. I think by the time the environment.js
is loaded, the Brocfile.js
has already loaded and created the new Ember app.
The addon may have access to config by the time it inlines content on the page. Maybe it could pick up config and insert it. For example:
//myScript.js
console.log('{{signOutUrl'}});
//Brocfile.js
inlineContent: {
file: 'myScript.js'
replace: 'signOutUrl'
//environment.js
if (environment === 'development') { ENV.signOutUrl: 'signout.com' }
Can the file you are importing be ran thru the babel compiler so I can use things like imports?
In this example (https://github.com/gdub22/ember-cli-inline-content#rendering-a-string-of-content-instead-of-a-file), when you attempt to add empty string ''
as content, you get this error.
Path must be a string. Received { content: '' }
TypeError: Path must be a string. Received { content: '' }
at assertPath (path.js:7:11)
at Object.join (path.js:1211:7)
at InlineContentRenderer.readFile (/Users/jasonkim/work/node/webclient-cli/node_modules/ember-cli-inline-content/index.js:68:23)
at InlineContentRenderer.contentFor (/Users/jasonkim/work/node/webclient-cli/node_modules/ember-cli-inline-content/index.js:43:22)
at /Users/jasonkim/work/node/webclient-cli/node_modules/ember-cli/lib/broccoli/ember-app.js:1539:49
at Array.reduce (native)
at EmberApp.contentFor (/Users/jasonkim/work/node/webclient-cli/node_modules/ember-cli/lib/broccoli/ember-app.js:1538:33)
at replacement (/Users/jasonkim/work/node/webclient-cli/node_modules/broccoli-config-replace/index.js:86:36)
at RegExp.[Symbol.replace] (native)
at RegExp.[Symbol.replace] (native)
I think this is intended. We should be able to render empty string if we want to.
i made a inline/ directory for inline template files,
now ,once template files changed, can't reload ;
i can mv inline/ to app/, once reload is ok ,but the content is old ;
so, is it possible to implement this feature ?
thanks for all mind .
Link over from ember-cli/ember-cli#2244
inlineContent: {
'google-analytics' : {'ext/google-analytics.js', env: ['test', 'prod']},
'bar' : {'http://google.de/some-place/analytics.js', env: ['all']},
'fast-style' : 'ext/red.css' // don't break old syntax
}
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.