随笔分类 - Webpack
Webpack
摘要:我们知道React等前端框架默认都是SPA+CSR (单页应用+客户端渲染),所谓客户端渲染就是服务端返回:空页面 + JS bundle文件,在客户端浏览器再通过JS bundle对指定的DOM节点进行页面渲染(生成html、css)。 这种CSR模式有两个主要问题 1:在加载完js bundle
阅读全文
摘要:新建项目文件夹: mkdir react-setup cd react-setup mkdir public src touch public/index.html touch src/app.js 配置及依赖: npm init -y npm install webpack webpack-cli
阅读全文
摘要:一) 安装基础依赖 Npm init -y npm install webpack webpack-cli --save-dev npm install typescript ts-loader --save-dev npm install jest @types/jest ts-jest --sa
阅读全文
摘要:Webpack.config.js的entry属性定义了打包文件的入口点。 参考:https://webpack.docschina.org/configuration/entry-context/#entry 但在实践中开发人员可能会发现其不便之处:对于multi-page app,需要为每个js
阅读全文
摘要:参考:https://webpack.js.org/guides/development/ 1:Webpack.config.js 加入 mode: 'development', 2: 使用source map devtool: 'inline-source-map' 3: 使用webpack-de
阅读全文
摘要:一:基础设置 参考:https://webpack.js.org/guides/getting-started/ npm init -y npm install webpack webpack-cli --save-dev 代码: webpack.config.js const path = req
阅读全文