Coder Social home page Coder Social logo

How to use the cli? about mincer HOT 11 CLOSED

ricardograca avatar ricardograca commented on September 2, 2024
How to use the cli?

from mincer.

Comments (11)

ixti avatar ixti commented on September 2, 2024

Not sure why that happens for you, just tried and all succeeded:

mkdir /tmp/test && cd /tmp/test
echo '{ "dependencies": ["mincer"] }' > package.json
npm install
mkdir -p {app,vendor}/assets/javascripts
echo 'alert("BOOM");' > vendor/assets/javascripts/abc.js
echo '//= require abc' > app/assets/javascripts/main.js
node node_modules/.bin/mincer \
  --include app/assets/javascripts \
  --include vendor/assets/javascripts \
  --output public \
  main.js

find public -type f | while read filename; do
  echo "=== ${filename} ==="
  cat $filename
  echo
done

Outputs:

/tmp/test
`-- [email protected] 
  +-- [email protected] 
  | `-- [email protected] 
  +-- [email protected] 
  | `-- [email protected] 
  +-- [email protected] 
  +-- [email protected] 
  +-- [email protected] 
  +-- [email protected] 
  | `-- [email protected] 
  +-- [email protected] 
  +-- [email protected] 
  `-- [email protected] 

npm WARN test No description
npm WARN test No repository field.
npm WARN test No license field.
debug Compiled main.js (16ms)
Writing /tmp/test/public/main-cfa61cf97edbed15ba3d2a83208167b0.js
=== public/manifest.json ===
{
  "assets": {
    "main.js": "main-cfa61cf97edbed15ba3d2a83208167b0.js"
  },
  "files": {
    "main-cfa61cf97edbed15ba3d2a83208167b0.js": {
      "logical_path": "main.js",
      "mtime": "2016-05-20T11:57:42.000Z",
      "size": 34,
      "digest": "cfa61cf97edbed15ba3d2a83208167b0"
    }
  }
}
=== public/main-cfa61cf97edbed15ba3d2a83208167b0.js ===
alert("BOOM");//(=) require abc
;

from mincer.

ricardograca avatar ricardograca commented on September 2, 2024

I'm on mincer 1.3.0. I'll check if upgrading fixes this, and if not continue investigating what may be happening on my end.

from mincer.

ricardograca avatar ricardograca commented on September 2, 2024

I upgraded to the latest version and still no luck. Your example runs perfectly fine though, so I'll continue to investigate any possible differences and report back.

from mincer.

ricardograca avatar ricardograca commented on September 2, 2024

Obviously it was developer blindness/stupidity. The asset I was trying to compile was in a sub-directory of app/assets/javascripts so I was passing the wrong logical path in the command line. It should have been something like:

node_modules/.bin/mincer --include app/assets/javascripts --include vendor/assets/javascripts my-app/main.js

However it seems like the CLI utility has no way of compressing assets, or am I missing something?

from mincer.

ixti avatar ixti commented on September 2, 2024

Well, cli is pretty simple yeah. And honestly was implemented only as an attempt to match sprocket's CLI. But I don't see any realy practical usage of it. IMHO it's better to write your own runner that will be configure Mincer environment the way you need. And will be:

  • easier to read
  • easier to maintain
  • reliable
    etc... :D

from mincer.

ricardograca avatar ricardograca commented on September 2, 2024

Well, I just needed a one time compression of assets, so I thought I'd use the CLI. Would you take a PR to add compression support to the CLI? Something like:

mincer --include something --js-compressor uglify asset.js

from mincer.

ixti avatar ixti commented on September 2, 2024
#!/usr/bin/env node

var Mincer = require("mincer"),
    environment = new Mincer.Environment(__dirname);

environment.appendPath("app/assets/javascripts");
environment.appendPath("vendor/assets/javascripts");

environment.enable("autoprefixer");

environment.jsCompressor = "uglify";
environment.cssCompressor = "csswring";

var manifest = new Mincer.Manifset(environment, "public");

manifest.compile(["main.js"]);

from mincer.

ixti avatar ixti commented on September 2, 2024

Yeah. I'm OK with PR that will allw configure js/css compressor on CLI, as well as --enable.

from mincer.

ricardograca avatar ricardograca commented on September 2, 2024

What is --enable?

from mincer.

ixti avatar ixti commented on September 2, 2024

to enable different plugins, like autoprefixer for example

from mincer.

ricardograca avatar ricardograca commented on September 2, 2024

Ah! Good point :)

from mincer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.