types: add TypeScript declarations of webpack plugins (#6325)

close #6301
This commit is contained in:
katashin 2017-09-06 04:57:05 +09:00 committed by Evan You
parent 1b96ba7019
commit a67b795b36
5 changed files with 34 additions and 3 deletions

View File

@ -0,0 +1,3 @@
import { WebpackPlugin } from './types/plugin';
declare const Plugin: WebpackPlugin;
export = Plugin;

View File

@ -28,12 +28,13 @@
"lodash.template": "^4.4.0",
"lodash.uniq": "^4.5.0",
"resolve": "^1.2.0",
"source-map": "0.5.6",
"serialize-javascript": "^1.3.0"
"serialize-javascript": "^1.3.0",
"source-map": "0.5.6"
},
"devDependencies": {
"@types/node": "^7.0.22",
"typescript": "^2.3.3",
"@types/webpack": "^3.0.6",
"typescript": "^2.4.2",
"vue": "file:../.."
},
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer#readme"

View File

@ -0,0 +1,3 @@
import { WebpackPlugin } from './types/plugin';
declare const Plugin: WebpackPlugin;
export = Plugin;

View File

@ -0,0 +1,9 @@
import { Plugin } from 'webpack';
interface WebpackPluginOptions {
filename?: string;
}
export interface WebpackPlugin {
new (options?: WebpackPluginOptions): Plugin;
}

View File

@ -1,4 +1,7 @@
import Vue = require('vue');
import VueSSRClientPlugin = require('../client-plugin');
import VueSSRServerPlugin = require('../server-plugin');
import webpack = require('webpack');
import { readFileSync } from 'fs';
import { createRenderer, createBundleRenderer } from '../';
@ -82,3 +85,15 @@ bundleRenderer.renderToString(context, (err, html) => {
bundleRenderer.renderToStream(context).on('data', chunk => {
const html = chunk.toString();
});
// webpack plugins
webpack({
plugins: [
new VueSSRClientPlugin({
filename: 'client-manifest.json'
}),
new VueSSRServerPlugin({
filename: 'server-bundle.json'
})
]
});