如何将自己的玉文件用于webpack? [英] how to have use own jade file for webpack?

查看:90
本文介绍了如何将自己的玉文件用于webpack?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是webpack的新手,试图弄清楚如何在webpack-dev-server和我的webpack版本中使用自己的html文件.

I'm new to webpack and trying to figure out how to use my own html file in the webpack-dev-server, as well as my webpack build.

在我的app.js中,我有:

in my app.js I have:

require('!jade!index.jade')

,但是并不能像我期望的那样生成index.html.相反,看来充其量我可以得到html的字符串输出,这不是我想要的:

but that does not make an index.html as I would expect. Instead, it seems at best I can get a string output of my html, which isn't what I want:

var jade = require('!jade!index.jade')
jade() //outputs my html

如何获取它以输出index.html文件?如何让webpack-dev-server使用该html文件?

How do I get it to output an index.html file? How do I get the webpack-dev-server to use that html file?

我还应该提到我的玉器文件可能会引用手写笔文件

I should also mention my jade file will likely reference stylus files

推荐答案

我使用 jade-html-loader webpack.config.js中输入以下内容:

I use jade-html-loader with the following entry in webpack.config.js:

entry: ['./src/app.js', 'file?name=index.html!jade-html!./src/index.jade']

您将需要

npm install --save-dev file-loader jade-html-loader jade

这篇关于如何将自己的玉文件用于webpack?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆