webpack css loader 使用
备注:
main.css #app { text-align:center; } main.js require("./main.css"); const shortid = require("shortid"); const demo = require("./show.js"); demo(shortid.generate());
webpack.config.js const path = require("path"); module.exports = { entry:"./main.js", output:{ filename:"bundle.js", path:path.resolve(__dirname,"./dist"), }, module:{ rules:[ { test: /\.css$/, use:['style-loader','css-loader'], } ] } }
yarn run build
https://webpack.js.org/guides/getting-started/
use:[ "style-loader",{ loader:"css-loader", options:{ mininize:true } } ] or require("syle-loader!css-loader?minimize!./mian.css")