Nicholas Bilyk
08/05/2020, 8:40 PMNicholas Bilyk
08/05/2020, 9:02 PMBrandon Saunders
08/05/2020, 10:44 PMNicholas Bilyk
08/06/2020, 3:58 AMNicholas Bilyk
08/06/2020, 4:17 AMlet HtmlWebpackPlugin = require("html-webpack-plugin");
config.output.filename = "[name].[contenthash].js";
config.plugins.push(
new HtmlWebpackPlugin({
template: 'D:\\my-absolute-path-works\\index.ejs'
})
);
Nicholas Bilyk
08/06/2020, 4:19 AMbashor
08/06/2020, 7:26 AMIlya Goncharov [JB]
08/06/2020, 7:38 AMwebpack.config.js
The only problem, that if you have template in your resources folder, and you have multi module project, you need to set path from webpack working directory to this resources
In this script you can use path
module of node.js
const path = require(‘path’)
tenplate = path.resolve(__dirname, <relative-path-to-template>) //__dirname = build/js/packages/module-name
Nicholas Bilyk
08/06/2020, 2:02 PMIlya Goncharov [JB]
08/06/2020, 2:13 PM<module>/build/processedResources
So you write something like that and it get path to processedResources
folder
path.resolve(__dirname, "../../../../module/build/processedResources")
In which case you get IllegalStateException
w/o message? Could you please send stacktrace?
It can be done with ./gradlew … --stacktrace
Nicholas Bilyk
08/06/2020, 2:19 PMNicholas Bilyk
08/06/2020, 2:37 PMdependencies {
compileOnly(devNpm("html-webpack-plugin", version = "4.3.0"))
}
2) In your project root, add a webpack.config.d folder
3) In your project's resources directory add an index.html without a <script> element for your main js.
4) Add a webpack.config.d/config.js file with the contents:
const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
config.output.filename = "[name].[contenthash].js";
config.plugins.push(
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "../../../../your-module-name/build/processedResources/js/main/index.html")
})
);
Ilya Goncharov [JB]
08/06/2020, 2:45 PMhmtl-webpack-plugin
? Seems that if index.html
is plain html, you can use just index.html
without this pluginNicholas Bilyk
08/06/2020, 3:16 PMIlya Goncharov [JB]
08/06/2020, 7:26 PM