【发布时间】:2016-09-24 02:52:02
【问题描述】:
假设我想(我的老板让我)使用 webpack,并且我的文件结构如下:
其中builds 是webpack 输出捆绑/编译src 文件夹的结果的位置,如果它存在于服务器上,我如何让index.html 指向bundle.js,即我要公开哪个文件夹通过express.static()?什么是正确的“webpack”方式来做到这一点,即一个简单的webpack.config,如下所示?我是否缺少有关其工作原理的一些基本知识?理想情况下,我想在我的 index.html
<html>
<script src='bundle.js'></script>
<!-- bundle.js spits a bunch of CSS into the html, dynamically builds elements, etc -->
</html>
或者这不是 webpack 中的工作方式?
webpack.config.js
module.exports = {
entry: './src/index.js',
output: {
path: 'builds',
filename: 'bundle.js',
},
module: {
loaders: [
{ test: /\.css$/,
loader: "style!css"
}
]
}
};
我试图通过the docs 和this oft-linked article 解决这个问题。
【问题讨论】:
标签: javascript html webpack