转载请注明出处:
npm install -g webpack
npm install webpack --save-dev
module.exports = 'It workd from content.js'
console.log(require('./content.js'))立即学习“前端免费学习笔记(深入)”;
webpack ./entry.js bundle.js
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"></head><body><script src="bundle.js"></script></body></html>
输出
It workd from content.js
webpack默认只支持js模块, 要打包css文件需要使用 css-loader处理css文件, style-loader应用样式
npm install css-loader style-loader
body { background-color: yellow;}
console.log(require('./content.js'))require('!style!css!./style.css')require('!style!css!./style.css')每次都写很长的加载器前缀很麻烦, 可以在编译命令指定加载器绑定到文件后缀名
webpack ./entry.js bundle.js --module-bind "css=style!css"
此时 entry.js可以简化
require('./style.css')将配置信息添加到 webpack.config.js配置文件后, 每次只需要执行 webpack即可完成打包任务
module.exports = { entry: './entry.js', output: {}}
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号