https://github.com/farism/gulp-elm-extract-assets
A plugin for extracting assets from a compiled elm application
https://github.com/farism/gulp-elm-extract-assets
Last synced: 6 months ago
JSON representation
A plugin for extracting assets from a compiled elm application
- Host: GitHub
- URL: https://github.com/farism/gulp-elm-extract-assets
- Owner: farism
- License: mit
- Created: 2017-08-21T04:28:08.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-21T04:28:23.000Z (almost 9 years ago)
- Last Synced: 2025-01-30T02:18:29.004Z (over 1 year ago)
- Language: JavaScript
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-elm-extract-assets [](https://circleci.com/gh/farism/gulp-elm-extract-assets/tree/master)
Given an compiled `.elm` file and a `tag`, this plugin will extract all assets using that `tag`. A vinyl object will be emitted for each extracted asset. Inspired by [elm-asset-path](https://github.com/NoRedInk/elm-asset-path) but trying to avoid the native requirement.
#### Usage
```js
const elmExtractAssets = require('gulp-elm-extract-assets')
gulp.src('main.js')
.pipe(elmExtractAssets({ tag: 'AssetUrl' }))
```
#### Options
```js
options = {
tag // (required) asset tag
cwd: process.cwd() // (optional) the root directory of your elm project
}
```
#### Example
on the elm side
```elm
-- Main.elm
module Main exposing (..)
import Html exposing (Html, div)
import Html.Attributes exposing (id, src)
import Assets exposing (url, elmLogo, css3Logo)
main : Html a
main =
div []
[ Html.img [ src (url elmLogo) ] []
, Html.img [ src (url css3Logo) ] []
]
```
```elm
-- Assets.elm
module Assets exposing (..)
type Asset
= AssetUrl String
url : Asset -> String
url asset =
case asset of
AssetUrl url ->
url
elmLogo =
AssetUrl "/src/elm.png"
css3Logo =
AssetUrl "/src/css3.png"
```
on the gulp side
```js
const elm = require('gulp-elm')
const elmExtractAssets = require('gulp-elm-extract-assets')
gulp.task('build', () => {
return gulp.src('Main.elm')
.pipe(elm())
.pipe(elmExtractAssets({ tag: 'AssetUrl '}))
.pipe(imagemin())
.pipe(revAll())
.pipe(gulp.dest('build'))
})
```