-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
112 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
module.exports = { | ||
pretty: false, | ||
bundleDir: '/assets/', | ||
remoteAsset: '//dkny.oss-cn-hangzhou.aliyuncs.com/1/icons', | ||
main: 'article0', | ||
route: '/article/', | ||
type: ['2020', 'Developer', 'Designer', 'Architect', 'Beginner', 'Fun!'], | ||
articles: [ | ||
{ | ||
id: 4, | ||
title: 'Vue/React的加载优化(高级篇)', | ||
author: 'ZJ Guo', | ||
about: ['Webpack', 'react', 'vue', 'angular', '阿里云', 'OSS'], | ||
time: '2015-08-30', | ||
content: 'JavaScript加载优化方案...', | ||
fileName: 'article1', | ||
}, | ||
{ | ||
id: 3, | ||
title: '新浪微博(Weibo.com)前端构建详解之BigPipe', | ||
author: 'ZJ Guo', | ||
about: ['BigPipe', 'architecture', 'weibo', 'Facebook'], | ||
time: '2015-07-01', | ||
content: '微博以及Facebook前端构建详解...', | ||
fileName: 'article1', | ||
}, | ||
{ | ||
id: 2, | ||
title: 'JavaScript代码的逆向读取', | ||
author: 'ZJ Guo', | ||
about: ['uglify', 'minify'], | ||
time: '2015-06-28', | ||
content: '微博前端代码的混淆分析', | ||
fileName: 'article1', | ||
}, | ||
{ | ||
id: 1, | ||
title: '如何写一手漂亮的React(一):state vs redux', | ||
author: 'ZJ Guo', | ||
about: ['react', 'redux'], | ||
time: '2015-06-15', | ||
content: '状态管理详解...', | ||
fileName: 'article1', | ||
}, | ||
{ | ||
id: 0, | ||
title: 'Welcome to Javascript.fun', | ||
author: 'ZJ Guo', | ||
about: ['javascript', 'node.js'], | ||
time: '2015-04-01', | ||
content: '为JavaScript社区不定期更新...', | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
const fs = require('fs'); | ||
const pug = require('pug'); | ||
const path = require('path'); | ||
const configJson = require('../../config.js'); | ||
|
||
module.exports = articleId => { | ||
if (!articleId) { | ||
module.exports = article => { | ||
if (!article.id) { | ||
return; | ||
} | ||
|
||
const configJson = JSON.parse( | ||
fs.readFileSync(path.join(__dirname, './viewModel_article.json')) | ||
const viewModel = Object.assign( | ||
{ | ||
page: 6, | ||
article, | ||
}, | ||
configJson | ||
); | ||
|
||
configJson.id = articleId; | ||
configJson.page = 6; | ||
configJson.article = configJson['article'].filter( | ||
v => v.id === configJson.id | ||
)[0]; | ||
|
||
if (process.env.NODE_ENV === 'development') { | ||
configJson.bundleDir = `/build/${configJson.article.fileName}.js`; | ||
viewModel.bundleDir = `/build/${viewModel.article.fileName}.js`; | ||
} else { | ||
configJson.bundleDir += `${configJson.article.fileName}.js`; | ||
viewModel.bundleDir += `${viewModel.article.fileName}.js`; | ||
} | ||
|
||
const pugPath = path.join( | ||
__dirname, | ||
`../../../views/article/${configJson.id}.pug` | ||
`../../../views/article/${viewModel.article.id}.pug` | ||
); | ||
const html = pug.renderFile(pugPath, configJson); | ||
|
||
const html = pug.renderFile(pugPath, viewModel); | ||
const folderPath = path.join( | ||
__dirname, | ||
`../../../public/article/${configJson.id}/` | ||
`../../../public/article/${viewModel.article.id}/` | ||
); | ||
if (!fs.existsSync(folderPath)) { | ||
fs.mkdirSync(folderPath); | ||
} | ||
const filePwd = path.join( | ||
__dirname, | ||
`../../../public/article/${configJson.id}/index.html` | ||
`../../../public/article/${viewModel.article.id}/index.html` | ||
); | ||
fs.openSync(filePwd, 'w'); | ||
fs.writeFileSync(filePwd, html); | ||
|
||
console.log(`render article ${configJson.id} success!`); | ||
console.log(`render article ${viewModel.article.id} success!`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
"use strict"; | ||
'use strict'; | ||
|
||
const webpackConfig = require('./generic/hot'); | ||
const configJson = require('../server/task/render/viewModel_article.json'); | ||
const article = configJson.article.filter(v => v.id === configJson.id)[0]; | ||
const configJson = require('../server/config'); | ||
const article = configJson.articles[0]; | ||
|
||
const entries = { | ||
main: ['./client/modules/main/index.js', 'webpack/hot/only-dev-server'], | ||
site: ['./client/modules/site/index.js', 'webpack/hot/only-dev-server'], | ||
devServerClient: 'webpack-dev-server/client?http://0.0.0.0:3000' | ||
devServerClient: 'webpack-dev-server/client?http://0.0.0.0:3000', | ||
}; | ||
|
||
entries[configJson.main] = ['./client/modules/article2/index.js', 'webpack/hot/only-dev-server']; | ||
entries[article.fileName] = ['./client/modules/article1/index.js', 'webpack/hot/only-dev-server'], | ||
|
||
webpackConfig.entry = entries; | ||
entries[configJson.main] = [ | ||
'./client/modules/article2/index.js', | ||
'webpack/hot/only-dev-server', | ||
]; | ||
(entries[article.fileName] = [ | ||
'./client/modules/article1/index.js', | ||
'webpack/hot/only-dev-server', | ||
]), | ||
(webpackConfig.entry = entries); | ||
webpackConfig.output = { | ||
publicPath: '/build', | ||
filename: "[name].js", | ||
filename: '[name].js', | ||
}; | ||
webpackConfig.devServer.historyApiFallback.index = 'main/'; | ||
|
||
|
||
module.exports = webpackConfig; | ||
module.exports = webpackConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters