# assetx

> Assets management

Latest version **0.1.3** (published 2015-10-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install assetx
pnpm add assetx
yarn add assetx
bun add assetx
```

Provides the command `assetx`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2015-10-02 |
| First published | 2015-07-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alexandre Dupuy |
| Maintainers | alexdpy |
| Keywords | asset, assetic, js, css |

## Links

- npm: https://www.npmjs.com/package/assetx
- Repository: https://github.com/AlexDpy/AssetX
- Issues: https://github.com/AlexDpy/AssetX/issues
- npm.io page: https://npm.io/package/assetx

## Dependencies (11)

- [mv](https://npm.io/package/mv.md) ^2.1.1
- [glob](https://npm.io/package/glob.md) ^5.0.13
- [gulp](https://npm.io/package/gulp.md) ^3.9.0
- [colors](https://npm.io/package/colors.md) ^1.1.2
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.3.1
- [selectn](https://npm.io/package/selectn.md) ^0.9.6
- [commander](https://npm.io/package/commander.md) ^2.8.1
- [gulp-concat](https://npm.io/package/gulp-concat.md) ^2.6.0
- [gulp-uglify](https://npm.io/package/gulp-uglify.md) ^1.2.0
- [coffee-script](https://npm.io/package/coffee-script.md) ^1.9.3
- [gulp-minify-css](https://npm.io/package/gulp-minify-css.md) ^1.2.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.3 (latest) — 2015-10-02
- 0.1.2 — 2015-09-18
- 0.1.1 — 2015-08-21
- 0.1.0 — 2015-07-19

## README

# AssetX

> Manage front-end assets

AssetX manages front-end assets and takes care about dev/production environments

##### Work in progress, please take care.

## Install

```
$ npm install -g assetx
```

## Usage

### Configuration

AssetX needs a yaml configuration file. Default is ./assetx.yml.

This is the configuration reference :

```yml
# assetx.yml

# (required) where AssetX will find view templates
views:
    - views/**/*.twig

# (required) where AssetX will find dev/prod assets
devFolder: web/.tmp_assets
prodFolder: web/assets

# (required) web path to dev/prod assets
devBaseUrl: /.tmp_assets
prodBaseUrl: /assets

# (optional, default to false) if true, prod assets file names will have a hash based on the dev assets content
# this can be overridden by the --force-cache-busting and --disable-cache-busting options
cacheBusting: true

# (optional) implement this to customize some of the tags AssetX will generate (./src/tags.coffee)
tags:
    twig:
        js: '<script type="text/javascript" src="%src%"></script>'

# (optional) implement this to override the gulp tasks AssetX will pipe (./src/tasks.coffee)
tasks:
    js:
        gulp-uglify: # this key will be used to require the gulp module
            # an array of arguments that will be applied on the module
            - { mangle: false }

# (required) list of assets AssetX will take into account
assets:
    css/style.css: # asset name must be suffixed by the mime-type extension, like .css or .js (path is relative to prodFolder)
        files: # list of dev assets to concatenate (path relative to devFolder)
            - css/**/*.css

    js/app.js:
        files:
            - js/app1.js
            - js/app2.js

    # global options (except 'views') can be override on each asset
    print.css:
        files:
            - css/print/**/*.css
        prodFolder: cdn_assets/css
        prodBaseUrl: 'http://cdn.my-project.com'
        tags:
            twig: '<link rel="stylesheet" href="%src%" media="print">'
        tasks:
            gulp-minify-css:
                - { keepSpecialComments: 0 }
```

### Views

In view templates, insert AssetX [tags](./src/tags.coffee) for each asset defined in the assetx.yml
```twig
{% if app.environment == 'prod' %}
    {#assetx prod:css/style.css#}{#endassetx#}
    {#assetx prod:print.css#}{#endassetx#}
{% else %}
    {#assetx dev:css/style.css#}{#endassetx#}
    {#assetx dev:print.css#}{#endassetx#}
{% endif %}
```

### Run AssetX

```bash
~/my-project $ assetx
```

Some options and other commands are available, just run assetx --help for more information

## License

[MIT](./LICENSE)


## Credits

Inspired by [gassetic](https://github.com/romanschejbal/gassetic)

---
_Source: https://npm.io/package/assetx · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
