Skip to content

Commit 398910a

Browse files
committed
replace watch with node-wather
1 parent 2ae7bb6 commit 398910a

13 files changed

Lines changed: 88 additions & 1488 deletions

package-lock.json

Lines changed: 16 additions & 1420 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,21 @@
4040
"glob": "^7.1.4",
4141
"mini-css-extract-plugin": "^0.8.0",
4242
"node-sass": "^4.12.0",
43+
"node-watch": "^0.6.3",
4344
"prop-types": "^15.7.2",
44-
"react": "^16.9.0",
45-
"react-dom": "^16.9.0",
45+
"react": "^16.10.0",
46+
"react-dom": "^16.10.0",
4647
"sass-loader": "^8.0.0",
47-
"watch": "^1.0.2",
4848
"webpack": "^4.41.0",
49-
"webpack-cli": "^3.3.9",
50-
"webpack-dev-server": "^3.8.1"
49+
"webpack-cli": "^3.3.9"
5150
},
5251
"scripts": {
5352
"clean:target": "babel-node ./tool/build.cleanup.js",
5453
"build:asset": "babel-node ./tool/build.asset.js",
5554
"build:page": "babel-node ./tool/build.page.js",
5655
"build:bundle": "babel-node ./tool/build.bundle.js",
5756
"build:water": "",
58-
"build": "npm run clean:target; npm run build:asset; npm run build:bundle; npm run build:page;",
59-
"start": "webpack-dev-server --open --mode development"
57+
"build": "npm run clean:target; npm run build:asset; npm run build:bundle; npm run build:page;",
58+
"start": "babel-node ./tool/build.watcher.js"
6059
}
6160
}

src/scripts/client/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import '../../styles/main.scss'; //Yep, that's right. You can import SASS/CSS files too! Webpack will run the associated loader and plug this into the page.
2+
3+
import {createGAScript} from './util/browser.util';
4+
5+
window.onload = function () {
6+
createGAScript();
7+
};

src/scripts/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Root = ({title,description,scripts,styles,rel, gaKey}) => {
1414
<Main>
1515
<div className="row">
1616
<aside>
17-
<p>left side</p>
17+
<p>Left Side</p>
1818
</aside>
1919
<section>
2020
<p>Main content</p>

src/scripts/main.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/scripts/pages/about.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const About = ({title,description,scripts,styles,rel, gaKey}) => {
1212
<body data-track={gaKey} className='container'>
1313
<Header title={title} />
1414
<Main>
15-
<h1>About React2Html</h1>
1615
<h1>About React2Html</h1>
1716
<p>More details can be found at <a href="https://github.com/modesty/react2html"> GitHub </a></p>
1817
</Main>

src/scripts/pages/contact.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const Contact = ({title,description,scripts,styles,rel, gaKey}) => {
1212
<body data-track={gaKey} className='container'>
1313
<Header title={title} />
1414
<Main>
15-
<h1>React2Html</h1>
15+
<h1>Contact Me</h1>
1616
<p>email the author: <a href="mailto:modestyz@hotmail.com?subject=About%20CoeProject%20Article">modestyz@hotmail.com</a></p>
1717
</Main>
1818
<Footer rel={rel} />

tool/base.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const Config = {
2121
src: {
2222
path: CUR_DIR + SRC_BASE,
2323
js_path: CUR_DIR + SRC_BASE + "/scripts",
24-
js_entry: CUR_DIR + SRC_BASE + "/scripts/main.js",
24+
js_entry: CUR_DIR + SRC_BASE + "/scripts/client/main.js",
2525
sass_path: CUR_DIR + SRC_BASE + "/styles",
2626
img_path: CUR_DIR + SRC_BASE + "/images",
2727
vendor_css: CUR_DIR + VENDOR_BASE + "/css",

tool/build.page.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import Conf from './base.config';
22
import helper from './build.transform';
33

44
function main() {
5-
helper.transformOnePage('index.js', './props/index.js', Conf.src.js_path, Conf.target.path);
6-
helper.transformLinkedPages('pages', 'props', Conf.src.js_path, Conf.target.path);
5+
helper.transformAllPages();
76
}
87

98
main();

tool/build.transform.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function transformOnePage(pageFile, propFile, srcFolder, destFolder) {
8282

8383
const file = path.join(srcFolder, pageFile);
8484
let Component = require(file);
85-
//purgeCache(file);
85+
purgeCache(file);
8686

8787
if (!Component) {
8888
console.log(`✗ Error: No component found at ${file}`);
@@ -115,7 +115,18 @@ function transformLinkedPages(dir, propDir, srcFolder, destFolder) {
115115
});
116116
}
117117

118+
function transformRootIndex() {
119+
transformOnePage('index.js', './props/index.js', Conf.src.js_path, Conf.target.path);
120+
}
121+
122+
function transformAllPages() {
123+
transformRootIndex();
124+
transformLinkedPages('pages', 'props', Conf.src.js_path, Conf.target.path);
125+
}
126+
118127
export default {
119128
transformOnePage,
120-
transformLinkedPages
129+
transformLinkedPages,
130+
transformRootIndex,
131+
transformAllPages
121132
};

0 commit comments

Comments
 (0)