webpack全局装好了,webpack本地也装好了,css-loader和style-loader也装好了。webpack entry.js bundle.js -w执行时,为什么总是只能监听一次样式修改,求教代码如下index.html<body><div id="app"></div><script src="bundle.js"></script></body>a.jsmodule.exports=" world";entry.jsvar oApp=document.getElementById('app');var a=require("./a");require("style!css!./style.css");
oApp.innerHTML="<h3>hello</h3>"+a;
1 回答
翻过高山走不出你
TA贡献1875条经验 获得超3个赞
根据你的代码我写了个 demo ,没发现问题。
<!-- index.html --><body><div id="app"></div><script src="bundle.js"></script></body>
// a.jsmodule.exports=" world";
// entry.jsvar oApp=document.getElementById('app');var a=require("./a");require("./style.css"); oApp.innerHTML="<h3>hello</h3>"+a;
/* style.css */body { background-color: #aaa}
// webpack.config.jsmodule.exports = { entry: './entry.js', output: { filename: 'bundle.js' }, module: { rules: [ { test: /.css$/, use: [ "style-loader", "css-loader" ] } ] } }
{ "name": "package.json", "version": "1.0.0", "description": "", "main": "index.js", "dependencies": {}, "devDependencies": { "css-loader": "^0.26.1", "style-loader": "^0.13.1", "webpack": "^2.2.0-rc.4" }, "scripts": { "start": "webpack -w", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC"}
添加回答
举报
0/150
提交
取消