node+webpack+react 多页面开发-终极架构

2018-11-09 10:42:27 +08:00
 leinov

仓库

https://github.com/leinov/webpack-react-multi-page

特性

安装&使用

// clone
git clone git@github.com:leinov/webpack-react-multi-page.git

// 安装依赖包
npm install

// 开发
npm run dev

// 编译打包
npm run build

// 启动生产页面
npm start

新创建页面在 src 下添加文件夹并创建pageinfo.json 然后npm run dev 即可

|-- src
    |-- index/
    |-- page2/
        |-- index.js
        |-- pageinfo.json

项目架构

技术使用

目录结构

|-- webpack-react-multi-pages //项目
    |-- dist //编译生产目录
        |-- index
            |-- index.css
            |-- index.js
        |-- about
            |-- about.css
            |-- about.js
        |-- images
        |-- index.html
        |-- about.html
    |-- node_modules //node 包
    |-- src //开发目录
        |-- index //index 页面打包入口
            |-- images/
            |-- js
                |-- app.js// 业务 js
            |-- index.sass
            |-- index.js //页面 js 入口
        |-- about //about 页面打包入口
            |-- images/
                |--js
                    |-- app.js// 业务 js
            |-- about.sass
            |-- about.js //页面 js 入口
        |-- template.html // html 模板
        |-- style.sass //公共 sass
    |-- webpackConfig //在 webpack 中使用
        |-- getEntry.js //获取入口
        |-- getFilepath.js //src 下需要打包页面文件夹
        |-- htmlconfig.js //每个页面 html 注入数据
    |-- package.json
    |-- .gitignore
    |-- webpack.config.js //webpack 配置文件
    |-- www.js //生产启动程序

完整 wiki

3150 次点击
所在节点    程序员
21 条回复
yokyj
2018-11-17 14:36:20 +08:00
强烈安利 umijs

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/506023

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX