【问题标题】:How to setup webpack for express.js application, not react app?如何为 express.js 应用程序设置 webpack,而不是响应应用程序?
【发布时间】:2015-12-16 22:47:36
【问题描述】:

我需要使用 Express.js、jade 和 less 创建应用程序,并希望将应用程序与 webpack 打包在一起。 整个互联网上到处都是关于为 react 设置 webpack 的文章,但没有一篇关于使用模块化 javascript 为通常的 express 应用程序设置它的文章。

也没有一篇关于如何从 .less 文件制作 common.css 的文章

请帮帮我!

【问题讨论】:

  • 出于好奇,您在寻找表达自己缺乏的 webpack 的哪些好处?

标签: javascript express less pug webpack


【解决方案1】:
  • 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".  
    

!分开加载器

查看 webpack 文档中的配置 API 以获取有关如何设置捆绑过程的示例。这只是定义您的入口点和目的地的问题。

如果您正在寻找自动刷新,请查看 webpack 开发服务器 API。

【讨论】:

  • 我读过关于装载机的文章——它们没有问题。问题是从 .less 文件中获取 common.css 和其他块 css
猜你喜欢
  • 1970-01-01
  • 2018-02-18
  • 1970-01-01
  • 1970-01-01
  • 2018-09-06
  • 1970-01-01
  • 2012-06-13
  • 1970-01-01
  • 2023-03-16
相关资源
最近更新 更多