【发布时间】:2018-03-16 21:03:55
【问题描述】:
我正在使用 webpack html 插件从 graphiql.ejs 生成 html 页面,但是当我运行 npm start 时它没有生成 html 页面
webpack.config.js
var HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
plugins: [
new HtmlWebpackPlugin({
filename: "public/graphql/index.html", // Write the file to <public-path>/graphql/index.html
inject: false, // Do not inject any of your project assets into the template
GRAPHQL_VERSION: packageJSON.dependencies.graphql.replace(/[^0-9.]/g, ""), // Get the graphql version from my package.json
template: "graphiql.ejs" // path to template
})
]
};
我想在 /public/graphql 目录中生成 index.html。有谁知道我做错了什么?还有其他命令可以运行 webpack 吗?
【问题讨论】:
-
需要将其放入
plugins数组并导出webpack.github.io/docs/using-plugins.html -
@serge1peshcoff 我做了pastebin.com/1NgiM3kY 但它仍然没有生成
-
您的
npm start脚本是否运行webpack.config.js文件? -
@Jehy 不。它运行“开始”:“nodemon server.js --exec babel-node --presets es2015,stage-2”
-
@Jehy 如何也启用 webpack ?
标签: javascript node.js webpack graphql html-webpack-plugin