我尝试通过 file-loader
和 Webpack 3 加载我的 index.html
文件。
我的webpack.config.ts
看起来像这样:
import * as webpack from 'webpack';
const config: webpack.Configuration = {
entry: "./src/app.tsx",
output: {
filename: "bundle.js",
path: __dirname + "/dist"
},
devtool: "source-map",
resolve: {
extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js", ".html"]
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "awesome-typescript-loader"
}, {
test: /\.html$/,
loader: "file-loader"
}
]
}
};
export default config;
不幸的是,它没有将我的 src/index.html
文件加载到 dist
文件夹中。我究竟做错了什么?如何将src
文件夹中的索引文件获取到dist
文件夹中?
最佳答案
您可以使用html-webpack-plugin
.
{
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html'
})
]
}
关于typescript - 如何使用 Webpack 3、Typescript 和文件加载器加载 index.html 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44930804/