what
This article focuses on how to quickly build a multi-page application using Dawn.
why
A single page has many advantages and disadvantages. The current situation of our company is more suitable for the use of multi-page applications, which not only improves the development efficiency, ensures user experience, but also greatly compatible with the original PHP system.
how
-
Second one, prepare the raw materials
$ npm install dawn -g $ mkdir demoCopy the code
-
Second, initialize the application
// react $ dn init -t reactCopy the code
- Third, multi-page configuration
in./src
In, copy and modify index.js to the desired page name. Of course, it can also be a single page application without copying or modifying it.dawn
It will automatically read./src
In thejs
As an entry (excluding subdirectories)js
)
At this point, the multi-page application has been built
extra
Based on this, I made some additional configurations
- State management solutions refer to this articleUse Dawn engineering tools to practice MobX data flow management scheme”Or maybe it’s because this article is not
Mobx
Good practice, I founddawn
This tool -
Height configure webpack and create webpack.config.js under./. Here’s an example:
Module. exports = function(configs,webpack, CTX){//configs is the default configuration, It can be modified here //webpack current webpack instance // CTX current build "context instance" configs.plugins.push(new webpack.defineplugin ({"process.env": { NODE_ENV: JSON.stringify("production") } })); };Copy the code
-
Move the entry files to the pages folder under new./ SRC and change the dev and Build webpack items under./.dawn/pipe.yml
entry: ./src/pages/*.jsCopy the code
- Modify the
./src/assets/*.html
Add content required by the business