Answer the question
In order to leave comments, you need to log in
How to exclude require parsing in module list in webpack?
Guru advice needed. There is a directory containing jade templates. I want to make simple compilation in html. That is the simple principle "to compile and spit out" is necessary. In some js modules, of course, these jade templates are required, which are processed by such a chain of file!jade-html loaders in the webpack config. That is, html is first compiled, which is passed to the file-loader, which saves the compiled version in the directory. The problem is that after running webpack, additional modules are created in the build, due to the fact that the js entry point has require("./tmpl.jade"). How can I make loaders run, but the presence of this require does not lead to the creation of modules in the assembly of this entry point?
Example:
webpack.config.js:
"use strict";
let path = require("path");
module.exports = {
context: __dirname,
entry: {
index: "./js/index"
},
output: {
path: path.resolve(__dirname, "./dist"),
filename: "./[name].min.js",
publicPath: "/"
},
plugins: [],
module: {
loaders: [
{ test: /\.jade$/, loader: "file?name=[name].html!jade-html" }
]
}
};
"use strict";
require("./template.jade");
console.log("etc");
...
/* 0 */
/*!*************************!*\
!*** ./js/index.js ***!
\*************************/
function(module, exports, __webpack_require__) {
"use strict";
__webpack_require__(/*! ./template.jade */ 1);
console.log("etc");
},
/* 1 */
/*!********************************!*\
!*** ./js/template.jade ***!
\********************************/
function(module, exports, __webpack_require__) {
module.exports = __webpack_require__.p + "./dist/template.html";
}
...
...
/* 0 */
/*!*************************!*\
!*** ./js/index.js ***!
\*************************/
function(module, exports, __webpack_require__) {
"use strict";
console.log("etc");
}
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question