I just read Dart's article on Assets and Transformers and want to make sure I am understanding the correct way of structuring your asset directory.
Say my project name is MyApp, and it should produce - after cross-compiling - a JavaScript file called myapp.dart.js. Here is how I have the asset directory set up:
MyProject/
asset/
bootstrap/
css/
...
fonts/
...
js/
...
myapp/
... myapp's CSS and images
...other package's assets
web/
...
Am I doing this right? Or should I be placing my assets some place else, or in a different convention?
Yes it's fine this way.
The asset directory is currently only supported by pub serve and pub build but not by the web server integrated into the Darteditor.
Related
I'm using Angular5 and webpack for generate the dist folder.
For generating the assets folder i'm using the "copy-webpack-plugin". It copies the assets folder from /src/assets into /dist folder.
The problem is: all the path used by a admin console template of my src code uses relative paths starting from "assets/..." and the server include /dist/assets. All static resources will throw 404 not found.
What is the best way to include an assets folder into a dist folder?
I would recommend using the file-loader designed for this very purpose.
Once you have it configured in your webpack.config.js you can import paths to your files for use in JavaScript, as well as HTML templates if you're also using the html-loader.
const myImageUrl = require('./path/to/an/image.png')
doSomething(myImageUrl)
I'm used to building ng applications using just Angular and with this typical structure:
app
js
home
home.controller.js
home.directive.js
shared
usedByAll.controller.js
usedByAll.directive.js
templates
home.html
test
e2e
protractor tests
node_modules
index.html
package.json
So that when someone else coming in wants to catch up they just need to run
npm install
to install all the dependencies listed into their node_modules folder saving them time.
But recently I've started working on a Ruby-on-Rails project that is looking to angularize some of its components. This naturally means they're following their own MVC style and project structure and the angular stuff has been restricted to the following folders:
app/assets/javascripts/angular-components/component1
component2
component3
lib/angular.js
angular-mocks.js
etc
This is fine for development but when it comes down to testing I think this could be a problem. So my questions are really the following:
1 - When installing new modules via npm and attempting to save them as devDependencies
npm install karma --save-dev
to the package.json file, doesn't it mean you should have the node_modules folder at the root as well as the package.json file at the root?
2 - Should the karma.conf.js file, like the node_modules folder and package.json file, always be at the absolute root of the application?
Thanks
In many rails/angular applications you can see that Angular is tucked away inside the app/assets/javascripts folder. I personally don't like mixing and matching what I'm using when it comes to pages - i.e. go and get a Rails generated view or this one is an Angular one so go there.
Instead I broke out the two. Essentially the Rails part of this just functions as an API whereas Angular now handles the front end entirely. This allows you to treat the angular part nearly as a standalone app, following the typical angular structure. By doing this you can have the karma.conf.js file at the root of this folder.
ExampleAppName
- app (All Angular stuff is in here)
- src
- gulpfile.js
- karma.conf.js
- package.json
- api (All rails stuff is in here)
- rails stuff
I use Bower to manage dependencies in the form of Sass and JavaScript libraries. In almost all cases I reference these libraries directly from my Sass, CoffeeScript and JavaScript.
My build process concatenates and compresses the resultant assets. These combined stylesheets and JavaScripts also have sourcemaps. With the Bower-managed libraries coming straight from the bower_components directory, the sourcemaps create a dependency on having the bower_components directory publicly available.
When considering Bower alone, it's obvious that bower_components should be ignored by version control and referenced directly, but when adding the sourcemap aspect it starts to get a little blurry for me.
On the particular project I'm working on now I check compiled assets into version control to avoid having to compile them on Heroku. This might even try to force me to check the whole bower_components directory in. Yuck.
Thanks in advance if anyone has advice.
I'm trying to implement theme from external developers in grails using asset-pipeline plugin
theme structure:
-css
--patterns
--plugins
--animate.css
--bootstrap.css
...
-js
--plugins
--bootstrap.js
...
-img
-font-awesome
--css
--fonts
--less
--scss
...
If I import all files in appropriative directories of assets (stylesheets, javascript, images) many problem arise, ex:
-project/img/sample.jpg not found
-assets/bootstrap.css.map 404 (Not Found) (there is no such file)
and variuos js errors
when I use resource plugins and keep theme's folders structure everything works fine
So my question is how to use asset-pipeline with predefined theme?
Solved with using <asset:javascript src="xx.js" /> for each entry in order of source page
I have installed into a new project in codekit the following components:
jquery
animate.css
normalize
Modernizer
I understand that keeping these components in the bower directory is recommended so these files are easily updated. However, do we link to these in our html files directly? My sass files get compiled and outputted to assets/css but there aren't any sass files in the bower components and creating them in the original folder would, I assume, get overridden if I was to upgrade. Seems very odd to me to upload the entire bower_components file to the production server with all the dependent files. I have been building site for a long time without all this node, git, grunt, bower, et al stuff. I see the value in it, but I'm having a tough time getting up to speed. Any help sure would be appreciated.
In most cases, you would want to include the third-party components (e.g. css, javascript, ... files) within your own master css or javascript file and then minimize that file for production. For example, my folder structure looks like:
bower_components/
...
release/
css/
styles.min.css
img/
...
js/
scripts.min.js
src/
images/
...
scripts/
scripts.js
styles/
styles.less
templates/
...
And then, within styles.less, I might have:
#import (less) "../../bower_components/normalize-css/normalize.css";
Or within scripts.js I could have:
//#codekit-prepend "../../bower_components/jquery/dist/jquery.js"
I have CodeKit set to generate the minified versions in release/ from those files. The only files that go to production are all of the files in the release/ folder.