Skip to content

Commit

Permalink
➖ remove prerender-spa-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
nicejade committed Mar 2, 2023
1 parent 2bd99ee commit 1d0a6b3
Show file tree
Hide file tree
Showing 6 changed files with 5,442 additions and 3,531 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry="https://registry.npm.taobao.org"
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ yarn start
yarn deploy
```

>关于本应用构建:因采用 [prerender-spa-plugin](https://github.com/chrisvfritz/prerender-spa-plugin) 以解决 SPA SEO 问题,故而,您需要在根目录下创建 `arya.config.js`,根据 *arya.config.sample.js* 中示例格式,来设定 `executablePath` 参数,从而指定插件中捆绑的 **Chromium** 所在目录,使得 `prerender-spa-plugin` 可以正常工作。更多详情,可以参见 [Puppeteer 安装注意事项](https://www.jeffjade.com/2019/06/14/156-puppeteer-robot/#%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85)
## 特别鸣谢

[Arya](https://markdown.lovejade.cn/?utm_source=github.com) 的产生,得益于 [vditor](https://github.com/b3log/vditor):一款浏览器端的 Md 编辑器,同时也离不开 [vue、reveal.js 等开源库](https://github.com/nicejade/markdown-online-editor/blob/master/package.json#L25-L64)的支持,感谢 🙌。
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"less-loader": "^5.0.0",
"lint-staged": "^9.2.5",
"onchange": "^6.1.0",
"prerender-spa-plugin": "^3.4.0",
"prettier-eslint-cli": "^5.0.0",
"size-plugin": "^2.0.0",
"svg-sprite-loader": "^4.1.6",
Expand Down
24 changes: 15 additions & 9 deletions src/pages/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default {
return {
isLoading: true,
isMobile: window.innerWidth <= 960,
vditor: null
vditor: null,
}
},

Expand All @@ -33,7 +33,7 @@ export default {
},

components: {
HeaderNav
HeaderNav,
},

mounted() {
Expand All @@ -55,7 +55,7 @@ export default {
mode: 'sv',
preview: {
delay: 100,
show: !this.isMobile
show: !this.isMobile,
},
outline: true,
upload: {
Expand All @@ -70,8 +70,8 @@ export default {
request.open('POST', 'https://sm.ms/api/upload')
request.onload = that.onloadCallback
request.send(formData)
}
}
},
},
}
this.vditor = new Vditor('vditor', options)
this.vditor.focus()
Expand All @@ -81,15 +81,15 @@ export default {
if (currentTarget.status !== 200) {
return this.$message({
type: 'error',
message: currentTarget.status + ' ' + currentTarget.statusText
message: currentTarget.status + ' ' + currentTarget.statusText,
})
}
let resp = JSON.parse(currentTarget.response)
let imgMdStr = ''
if (resp.code === 'invalid_source') {
return this.$message({
type: 'error',
message: resp.message
message: resp.message,
})
}
if (resp.code === 'image_repeated') {
Expand All @@ -104,8 +104,8 @@ export default {
if (!savedMdContent.trim()) {
localStorage.setItem('vditorvditor', defaultText)
}
}
}
},
},
}
</script>

Expand All @@ -124,9 +124,15 @@ export default {
height: calc(100vh - 100px);
margin: 20px auto;
text-align: left;
.vditor-toolbar {
border-left: 1px solid #d1d5da;
border-right: 1px solid #d1d5da;
}
.vditor-content {
height: auto;
min-height: auto;
border: 1px solid #d1d5da;
border-top: none;
}
}
.vditor-reset {
Expand Down
50 changes: 12 additions & 38 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const path = require('path')
const SizePlugin = require('size-plugin')
const PrerenderSPAPlugin = new require('prerender-spa-plugin')

const isProductionEnvFlag = process.env.NODE_ENV === 'production'

Expand Down Expand Up @@ -43,7 +42,7 @@ module.exports = {

// tweak internal webpack configuration.
// see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
chainWebpack: config => {
chainWebpack: (config) => {
config.resolve.alias
.set('vue$', 'vue/dist/vue.esm.js')
.set('@helper', resolveRealPath('src/helper'))
Expand All @@ -63,7 +62,7 @@ module.exports = {
.loader('svg-sprite-loader')
.options({
name: '[name]-[hash:7]',
prefixize: true
prefixize: true,
})

const splitOptions = config.optimization.get('splitChunks')
Expand All @@ -88,16 +87,16 @@ module.exports = {
minChunks: 2,
priority: -20,
chunks: 'initial',
reuseExistingChunk: true
reuseExistingChunk: true,
},
element: {
name: 'element',
test: /[\\/]node_modules[\\/]element-ui[\\/]/,
chunks: 'initial',
// 默认组的优先级为负数,以允许任何自定义缓存组具有更高的优先级(默认值为0)
priority: -30
}
}
priority: -30,
},
},
})
)

Expand All @@ -110,32 +109,7 @@ module.exports = {
},

configureWebpack: {
plugins: [
isProductionEnvFlag
? new PrerenderSPAPlugin({
// Required - The path to the webpack-outputted app to prerender.
staticDir: path.join(__dirname, 'dist'),
// Required - Routes to render.
routes: [
'/',
'/about-arya',
'/export/pdf',
'/export/png',
'/export/jpeg',
'/export/ppt'
],
render: new PrerenderSPAPlugin.PuppeteerRenderer({
renderAfterTime: 3000
}),
minify: {
collapseWhitespace: true,
keepClosingSlash: true,
sortAttributes: true
}
})
: () => {},
isProductionEnvFlag ? new SizePlugin() : () => {}
]
plugins: [isProductionEnvFlag ? new SizePlugin() : () => {}],
},

// use thread-loader for babel & TS in production build
Expand All @@ -156,15 +130,15 @@ module.exports = {
favicon16: 'img/icons/favicon-16x16.png',
appleTouchIcon: 'img/icons/apple-touch-icon.png',
maskIcon: 'img/icons/safari-pinned-tab.svg',
msTileImage: 'img/icons/mstile-150x150.png'
msTileImage: 'img/icons/mstile-150x150.png',
},
// configure the workbox plugin (GenerateSW or InjectManifest)
workboxPluginMode: 'InjectManifest',
workboxOptions: {
// swSrc is required in InjectManifest mode.
swSrc: 'public/service-worker.js'
swSrc: 'public/service-worker.js',
// ...other Workbox options...
}
},
},

// configure webpack-dev-server behavior
Expand All @@ -176,9 +150,9 @@ module.exports = {
hotOnly: false,
// See https://github.com/vuejs/vue-cli/blob/dev/docs/cli-service.md#configuring-proxy
proxy: null, // string | Object
before: () => {}
before: () => {},
},

// options for 3rd party plugins
pluginOptions: {}
pluginOptions: {},
}
Loading

0 comments on commit 1d0a6b3

Please sign in to comment.