File tree Expand file tree Collapse file tree 5 files changed +111
-16
lines changed
Expand file tree Collapse file tree 5 files changed +111
-16
lines changed Original file line number Diff line number Diff line change @@ -11,23 +11,43 @@ module.exports = {
1111 } ,
1212 {
1313 name : 'description' ,
14- message : 'How would you descripe the new project' ,
14+ message : 'How would you describe the new project' ,
1515 default : `Another Hypernova React project`
16- }
16+ } ,
17+ {
18+ name : 'hasSSR' ,
19+ type : 'confirm' ,
20+ message : 'Do you want to include Server-Side Rendering (SSR)' ,
21+ default : true
22+ } ,
1723 ]
1824 } ,
19- actions : [
20- {
21- type : 'add' ,
22- files : '**'
23- } ,
24- {
25- type : 'move' ,
26- patterns : {
27- gitignore : '.gitignore'
25+ actions : function ( ) {
26+ return [
27+ {
28+ type : 'add' ,
29+ files : '**' ,
30+ filters : {
31+ 'webpack.client.config.js' : ! this . answers . hasSSR ,
32+ 'package.client.json' : ! this . answers . hasSSR
33+ }
34+ } ,
35+ {
36+ type : 'move' ,
37+ patterns : {
38+ 'webpack.client.config.js' : 'webpack.config.js' ,
39+ 'package.client.json' : 'package.json' ,
40+ [ `src/${ this . answers . hasSSR ? 'index' : 'client' } .js` ] : 'src/index.js'
41+ }
42+ } ,
43+ {
44+ type : 'move' ,
45+ patterns : {
46+ gitignore : '.gitignore'
47+ }
2848 }
29- }
30- ] ,
49+ ]
50+ } ,
3151 async completed ( ) {
3252 await this . npmInstall ( )
3353 this . showProjectTips ( )
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " <%= name %>" ,
3+ "description" : " <%= description %>" ,
4+ "version" : " 0.0.0" ,
5+ "scripts" : {
6+ "build" : " webpack --mode production" ,
7+ "dev" : " webpack-dev-server --mode development" ,
8+ "lint" : " eslint ./ --ignore-pattern dist/"
9+ },
10+ "dependencies" : {
11+ "express" : " ^4.17.1" ,
12+ "hypernova" : " ^2.5.0" ,
13+ "nova-react" : " ^1.0.2" ,
14+ "prop-types" : " ^15.7.2" ,
15+ "react" : " ^16.8.3" ,
16+ "react-dom" : " ^16.8.3"
17+ },
18+ "devDependencies" : {
19+ "@babel/core" : " ^7.5.5" ,
20+ "@babel/runtime" : " ^7.5.5" ,
21+ "babel-loader" : " ^8.0.6" ,
22+ "babel-preset-airbnb" : " ^4.0.1" ,
23+ "css-loader" : " ^2.1.1" ,
24+ "eslint" : " ^5.14.1" ,
25+ "eslint-config-airbnb" : " ^18.0.1" ,
26+ "eslint-plugin-import" : " ^2.18.2" ,
27+ "eslint-plugin-jsx-a11y" : " ^6.2.3" ,
28+ "eslint-plugin-react" : " ^7.14.3" ,
29+ "eslint-plugin-react-hooks" : " ^1.7.0" ,
30+ "webpack" : " ^4.29.5" ,
31+ "webpack-cli" : " ^3.2.3" ,
32+ "webpack-dev-server" : " ^3.8.0"
33+ }
34+ }
Original file line number Diff line number Diff line change 1111 "dependencies" : {
1212 "express" : " ^4.17.1" ,
1313 "hypernova" : " ^2.5.0" ,
14- "nova-react" : " ^1.0.2-alpha.0 " ,
14+ "nova-react" : " ^1.0.2" ,
1515 "prop-types" : " ^15.7.2" ,
1616 "react" : " ^16.8.3" ,
1717 "react-dom" : " ^16.8.3"
Original file line number Diff line number Diff line change 1- import { renderReact } from 'nova-react' ;
1+ import { mountComponent , loadById , load } from 'nova-react' ;
22
33import Example from './components/Example' ;
44
5- renderReact ( 'Example' , Example ) ;
5+ const render = ( name , { node, data } ) => {
6+ if ( name === 'Example' ) {
7+ return mountComponent ( Example , node , data )
8+ }
9+ }
10+
11+ document . addEventListener ( 'NovaMount' , ( { detail } ) => {
12+ const { name, id } = detail
13+
14+ const payload = loadById ( name , id )
15+
16+ if ( payload ) {
17+ render ( name , payload )
18+ }
19+ } )
20+
21+ load ( 'Example' ) . forEach ( render . bind ( null , 'Example' ) )
Original file line number Diff line number Diff line change 1+ const path = require ( 'path' ) ;
2+
3+ module . exports = {
4+ target : 'web' ,
5+ node : {
6+ fs : 'empty' ,
7+ module : 'empty' ,
8+ } ,
9+ output : {
10+ path : path . join ( __dirname , 'dist' ) ,
11+ filename : 'client.js' ,
12+ } ,
13+ module : {
14+ rules : [
15+ {
16+ test : / \. j s | \. j s x $ / ,
17+ exclude : / n o d e _ m o d u l e s / ,
18+ use : 'babel-loader' ,
19+ } ,
20+ ] ,
21+ } ,
22+ resolve : {
23+ extensions : [ '.js' , '.jsx' ] ,
24+ } ,
25+ } ;
You can’t perform that action at this time.
0 commit comments