Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup webpack for express.js application, not react app?

I need to create application with Express.js, jade and less and want to assemble application in bundles with webpack. Whole internet is full of articles about setup webpack for react but no one about setting up it for usual express application with modular javascript.

There is also no one article about how to make common.css from .less files

Help me please!

like image 277
Vadim Avatar asked Nov 09 '22 04:11

Vadim


1 Answers

  • https://github.com/webpack/less-loader
  • https://github.com/webpack/jade-loader

    require("jade!./template.jade");  
    // => uses the "jade-loader" (that is installed from npm to "node_modules")  
    //    to transform the file "template.jade"  
    
    require("!style!css!less!bootstrap/less/bootstrap.less");  
    // => the file "bootstrap.less" in the folder "less" in the "bootstrap"  
    //    module (that is installed from github to "node_modules") is  
    //    transformed by the "less-loader". The result is transformed by the  
    //    "css-loader" and then by the "style-loader".  
    

separate loaders with !

check out the configuration API in the webpack docs for examples on how to set up the bundling process. It's just a matter of defining your entry points and your destination.

If you're looking for auto-refreshing look at the webpack dev server API.

like image 197
tells Avatar answered Nov 14 '22 21:11

tells