现在可以用html-webpack-inline-source-plugin插件了,很方便。
只需要加一句:inlineSource: '.(js|css)$' 匹配用的是正则。
具体的可以去github看:https://github.com/DustinJackson/html-webpack-inline-source-plugin
只需要加一句:inlineSource: '.(js|css)$' 匹配用的是正则。
具体的可以去github看:https://github.com/DustinJackson/html-webpack-inline-source-plugin
2017-06-11
windows的用户注意了!运行以下代码要将单引号变为双引号才可以通过编译。这狗币老师不提醒!
webpack hello.js hello.bundle.js --module-bind "css=style-loader!css-loader "
webpack hello.js hello.bundle.js --module-bind "css=style-loader!css-loader "
2017-06-11
在exclude属性后面应该跟正则/node_modules/, 不用加引号不是字符串,这样才能真正匹配,用dirname+的形式也是不行的。我试了一下,不用的话是6秒多,加上exclude只有1秒多了
2017-06-10
我编译后 尾部是这样的?
/******/ ([
/* 0 */
/***/ (function(module, exports) {
throw new Error("Module parse failed: C:\\xampp\\htdocs\\webPack\\hello.js Unexpected token (1:9)\nYou may need an appropriate loader to handle this file type.\n| function (str){\r\n| \talert(str)\r\n| }");
/***/ })
/******/ ]);
/******/ ([
/* 0 */
/***/ (function(module, exports) {
throw new Error("Module parse failed: C:\\xampp\\htdocs\\webPack\\hello.js Unexpected token (1:9)\nYou may need an appropriate loader to handle this file type.\n| function (str){\r\n| \talert(str)\r\n| }");
/***/ })
/******/ ]);
2017-06-09
最赞回答 / 未成年面饼
const App = function(layer) { var dom = document.getElementById('app'); var layer = new layer(); dom.innerHTML = layer.tpl;}new App(layer);传参数后可以 你试试看
2017-06-09
在最小的2.6.1版本中要这样,才不会报错
module.exports = {
//入口文件
entry : {
main: "./src/script/main.js",
a: "./src/script/a.js"
},
//指定打包后的文件存放位置
output: {
//路径+文件名
filename: './dist/js/[Hash]-[name].js'
}
}
module.exports = {
//入口文件
entry : {
main: "./src/script/main.js",
a: "./src/script/a.js"
},
//指定打包后的文件存放位置
output: {
//路径+文件名
filename: './dist/js/[Hash]-[name].js'
}
}
2017-06-09