@financial-times/o-assets
Advanced tools
Comparing version 3.4.6 to 3.4.7
@@ -28,3 +28,3 @@ { | ||
"name": "@financial-times/o-assets", | ||
"version": "3.4.6", | ||
"version": "3.4.7", | ||
"dependencies": {}, | ||
@@ -36,4 +36,5 @@ "component": "o-assets", | ||
"origami-ci-tools": "^2.0.0", | ||
"remark-preset-lint-origami-component": "^1.0.0", | ||
"stylelint-config-origami-component": "^1.0.2" | ||
} | ||
} |
@@ -1,11 +0,10 @@ | ||
# Origami asset loader [![NPM version](https://img.shields.io/npm/v/@financial-times/health-check.svg)](https://www.npmjs.com/package/@financial-times/health-check) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](#licence) | ||
# o-assets [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](#licence) | ||
This component provides Sass and JavaScript utilities for reliably building paths to a component's static assets, such as CSS background images, fonts and JSON data files. This is needed because the URL path to load these assets will vary depending on how a product developer chooses to integrate the Origami component into their website. | ||
- [Overview](#overview) | ||
- [Sass](#sass) | ||
- [JavaScript](#javascript) | ||
- [Sass](#sass) | ||
- [URL routing](#url-routing) | ||
- [Using with the build service](#using-with-the-build-service) | ||
- [Using with the build service](#using-with-the-build-service) | ||
- [Contact](#contact) | ||
@@ -35,4 +34,4 @@ - [Licence](#licence) | ||
```js | ||
import { resolve } from 'o-assets'; | ||
xhr.open("get", resolve('data/2013/12/monthdata.csv', 'o-weather')); | ||
import {resolve} from 'o-assets' | ||
xhr.open('get', resolve('data/2013/12/monthdata.csv', 'o-weather')) | ||
``` | ||
@@ -48,4 +47,4 @@ | ||
* installed your Origami components using bower in the default `bower_components` directory; and | ||
* your `bower_components` directory is *inside* and at the base of the public web server document root of your project. | ||
- installed your Origami components using bower in the default `bower_components` directory; and | ||
- your `bower_components` directory is _inside_ and at the base of the public web server document root of your project. | ||
@@ -60,3 +59,3 @@ ### If you do have URL routing | ||
By default the global path is `/bower_components/`, which anticipates that you will put your local bower components directory in the public web root of your web server. However, as well as editing this, you can also set a custom path to any component, in whcih case the path for that component becomes: | ||
By default the global path is `/bower_components/`, which anticipates that you will put your local bower components directory in the public web root of your web server. However, as well as editing this, you can also set a custom path to any component, in whcih case the path for that component becomes: | ||
@@ -71,3 +70,3 @@ ```scss | ||
1. Global path prefix: `$o-assets-global-path` variable (in Sass) and `setGlobalPathPrefix` method (in JavaScript). Default is '/bower_components/'. | ||
1. Global path prefix: `$o-assets-global-path` variable (in Sass) and `setGlobalPathPrefix` method (in JavaScript). Default is '/bower_components/'. | ||
1. component path: This defaults to the name of the component and is set using methods that accept a map of component names and paths: | ||
@@ -78,3 +77,3 @@ | ||
```scss | ||
@include oAssetsSetcomponentPaths(( | ||
@include oAssetsSetModulePaths(( | ||
'o-example': '/assets/example' | ||
@@ -87,4 +86,4 @@ )); | ||
```js | ||
import { setcomponentPaths } from 'o-assets'; | ||
setcomponentPaths({ | ||
import { setModulePaths } from 'o-assets'; | ||
setModulePaths({ | ||
'o-example': '/assets/example' | ||
@@ -96,10 +95,10 @@ }); | ||
If you don't want to make local static assets available publicly, but you want to benefit from including Origami component CSS and JS into your own build, you can use the build service for your local assets. To do this, you will need to configure paths that *include the version of the component that you installed*, because otherwise the build service might give you assets from a different version of the component to the one you have. This is a significant gotcha, especially if you have non-shrinkwrapped Origami dependencies. Make sure your asset resource paths match the version you *actually installed*. | ||
If you don't want to make local static assets available publicly, but you want to benefit from including Origami component CSS and JS into your own build, you can use the build service for your local assets. To do this, you will need to configure paths that _include the version of the component that you installed_, because otherwise the build service might give you assets from a different version of the component to the one you have. This is a significant gotcha, especially if you have non-shrinkwrapped Origami dependencies. Make sure your asset resource paths match the version you _actually installed_. | ||
```js | ||
import { setcomponentPaths } from 'o-assets'; | ||
setcomponentPaths({ | ||
import {setModulePaths} from 'o-assets' | ||
setModulePaths({ | ||
'o-example': '//origami-build.ft.com/v2/files/o-example@1.2.3', | ||
'o-grid': '//origami-build.ft.com/v2/files/o-grid@2.3.4' | ||
}); | ||
'o-grid': '//origami-build.ft.com/v2/files/o-grid@2.3.4', | ||
}) | ||
``` | ||
@@ -113,3 +112,3 @@ | ||
---- | ||
--- | ||
@@ -116,0 +115,0 @@ ## Licence |
8
77
10339
4
110