diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:38:48 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 21:53:09 +0800 |
| commit | 26105034da4fcce7ac883c899d781f016559310d (patch) | |
| tree | c459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/vuepress/lib/webpack/createServerConfig.js | |
| parent | 2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff) | |
| download | xmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip | |
switch to vuepress
Diffstat (limited to 'node_modules/vuepress/lib/webpack/createServerConfig.js')
| -rw-r--r-- | node_modules/vuepress/lib/webpack/createServerConfig.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/node_modules/vuepress/lib/webpack/createServerConfig.js b/node_modules/vuepress/lib/webpack/createServerConfig.js new file mode 100644 index 00000000..e9f09835 --- /dev/null +++ b/node_modules/vuepress/lib/webpack/createServerConfig.js @@ -0,0 +1,58 @@ +module.exports = function createServerConfig (options, cliOptions) { + const fs = require('fs') + const path = require('path') + const WebpackBar = require('webpackbar') + const createBaseConfig = require('./createBaseConfig') + const VueSSRServerPlugin = require('vue-server-renderer/server-plugin') + const CopyPlugin = require('copy-webpack-plugin') + + const config = createBaseConfig(options, cliOptions, true /* isServer */) + const { sourceDir, outDir } = options + + config + .target('node') + .externals([/^vue|vue-router$/]) + .devtool('source-map') + + // no need to minimize server build + config.optimization.minimize(false) + + config + .entry('app') + .add(path.resolve(__dirname, '../app/serverEntry.js')) + + config.output + .filename('server-bundle.js') + .libraryTarget('commonjs2') + + config + .plugin('ssr-server') + .use(VueSSRServerPlugin, [{ + filename: 'manifest/server.json' + }]) + + const publicDir = path.resolve(sourceDir, '.vuepress/public') + if (fs.existsSync(publicDir)) { + config + .plugin('copy') + .use(CopyPlugin, [[ + { from: publicDir, to: outDir } + ]]) + } + + if (!cliOptions.debug) { + config + .plugin('bar') + .use(WebpackBar, [{ + name: 'Server', + color: 'blue', + compiledIn: false + }]) + } + + if (options.siteConfig.chainWebpack) { + options.siteConfig.chainWebpack(config, true /* isServer */) + } + + return config +} |
