Giter Club home page Giter Club logo

Comments (5)

harrytruong avatar harrytruong commented on July 4, 2024 2

πŸ‘ @famousgarkin, I agree. Those asset tools should be run separately to live-server.

For example, my working setup involves SASS and I run node-sass via CLI to meet my needs. When I make changes, my sass is compiled into css, which triggers a nice reload by live-server.


Tips for anyone using node-sass in combination with live-server:

  1. Always install live-server and node-sass as local dev dependencies to your project. This ensures you'll always have these tools frozen and stable for your project:

    $ npm install live-server node-sass --save-dev
  2. Running node-sass (assuming input of css/sass/style.sass, and output of css/style.css):

    $ ./node_modules/.bin/node-sass -w css/sass/style.scss -o css --source-map=true --output-style=compressed

    Note: node-sass catches changes from within the @import file calls, which is great.

  3. Running live-server:

    $ ./node_modules/.bin/live-server --no-browser --ignore=css/sass,css/style.css.map

    Note: live-server reloads when your sass files changes, but this isn't ideal. It should ignore those changes until node-sass finishes compiling the css/style.css file.

  4. To bring it all together, you can add a clean custom script to your package.json file:

    {
      // ... package.json metadata ...
      "scripts": {
        "dev-mode" : "node-sass -w css/sass/style.scss -o css --source-map=true --output-style=compressed & live-server --no-browser --ignore=css/sass,css/style.css.map"
      }
    }

    Then to run both tools, it's just npm run-script dev-mode!

from live-server.

tapio avatar tapio commented on July 4, 2024

Interesting idea. However, this project was born from my own needs and as I don't use Sass (or Less) nor CoffeeScript, I don't see myself working on this any time soon. I'm open to contributions though. :)

One thing I'm slightly worried is that after implementation the next issue would be either adding more directory name alternatives and/or adding configuration in order to make it work when someone else uses different conventions. That would make it less "zero-conf" and make it more complex. Not a huge deal though.

from live-server.

famousgarkin avatar famousgarkin commented on July 4, 2024

There's enough options available to watch and rebuild assets in parallel with running live server. Please keep it slim and focused, don't turn into another Grunt/Gulp/webpack/whatever do-it-all plugin and configuration craziness.

from live-server.

nikolaswise avatar nikolaswise commented on July 4, 2024

@famousgarkin +1

from live-server.

1j01 avatar 1j01 commented on July 4, 2024

(-1) @famousgarkin +1
Just run the live-server at the same time as whatever compilers/watchers/build tools.

from live-server.

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.