Node-sass: Wrong output file name

Created on 26 Apr 2017  ·  2Comments  ·  Source: sass/node-sass

The output file name is wrong when I run a command which also sets the options to generate a source map.

My command:

node-sass \
    -o /home/user/public_html/css \
    --output-style compressed \
    --source-map /home/user/public_html/css/bar.min.css.map \
    /home/user/public_html/css/src/foo.scss > /home/user/public_html/css/bar.min.css

Command output:

Rendering Complete, saving .css file...
Wrote CSS to /home/user/public_html/css/foo.css
Wrote Source Map to /home/user/public_html/css/bar.min.css.map

Problem:

  • file "foo.css" should have been named "bar.min.css"
  • file "bar.min.css" is created but it's empty
  • "bar.min.css.map" refers to "404.css" in it's content (should have been "bar.min.css")

Version info

  • NPM version (npm -v): 3.10.10
  • Node version (node -v): v6.10.2
  • Node Process (node -p process.versions):
    { http_parser: '2.7.0',
    node: '6.10.2',
    v8: '5.1.281.98',
    uv: '1.9.1',
    zlib: '1.2.11',
    ares: '1.10.1-DEV',
    icu: '56.1',
    modules: '48',
    openssl: '1.0.2k' }
  • Node Platform (node -p process.platform): linux
  • Node architecture (node -p process.arch): x64
  • node-sass version (node -p "require('node-sass').info -g"):
    node-sass 4.5.2 (Wrapper) [JavaScript]
    libsass 3.5.0.beta.2 (Sass Compiler) [C/C++]
  • npm node-sass versions (npm ls node-sass -g):
    /usr/lib
    └── [email protected]

Most helpful comment

By supplying the --output (-o) flag you have told node-sass to save the compiled output to that directory with the input file name.

The reason a blank file was created is because you've piped the empty output to bar.min.css.map.

If you want to control the output filename then shouldn't used the --output flag, but instead pipe the output the desired location.

node-sass \
    --output-style compressed \
    --source-map /home/user/public_html/css/bar.min.css.map \
    /home/user/public_html/css/src/foo.scss > /home/user/public_html/css/bar.min.css

All 2 comments

By supplying the --output (-o) flag you have told node-sass to save the compiled output to that directory with the input file name.

The reason a blank file was created is because you've piped the empty output to bar.min.css.map.

If you want to control the output filename then shouldn't used the --output flag, but instead pipe the output the desired location.

node-sass \
    --output-style compressed \
    --source-map /home/user/public_html/css/bar.min.css.map \
    /home/user/public_html/css/src/foo.scss > /home/user/public_html/css/bar.min.css

absolutely fixed the problem! thanks bro.

By supplying the --output (-o) flag you have told node-sass to save the compiled output to that directory with the input file name.

The reason a blank file was created is because you've piped the empty output to bar.min.css.map.

If you want to control the output filename then shouldn't used the --output flag, but instead pipe the output the desired location.

node-sass \
  --output-style compressed \
  --source-map /home/user/public_html/css/bar.min.css.map \
  /home/user/public_html/css/src/foo.scss > /home/user/public_html/css/bar.min.css

absolutely fixed the problem! thanks bro.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paulcpederson picture paulcpederson  ·  3Comments

NathanKleekamp picture NathanKleekamp  ·  4Comments

nagyfej picture nagyfej  ·  3Comments

samayo picture samayo  ·  3Comments

alexandrubau picture alexandrubau  ·  3Comments