Skip to content

Commit

Permalink
types: add TypeScript declarations of webpack plugins (#6325)
Browse files Browse the repository at this point in the history
close #6301
  • Loading branch information
ktsn authored and yyx990803 committed Sep 5, 2017
1 parent 1b96ba7 commit a67b795
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/vue-server-renderer/client-plugin.d.ts
@@ -0,0 +1,3 @@
import { WebpackPlugin } from './types/plugin';
declare const Plugin: WebpackPlugin;
export = Plugin;
7 changes: 4 additions & 3 deletions packages/vue-server-renderer/package.json
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions packages/vue-server-renderer/server-plugin.d.ts
@@ -0,0 +1,3 @@
import { WebpackPlugin } from './types/plugin';
declare const Plugin: WebpackPlugin;
export = Plugin;
9 changes: 9 additions & 0 deletions packages/vue-server-renderer/types/plugin.d.ts
@@ -0,0 +1,9 @@
import { Plugin } from 'webpack';

interface WebpackPluginOptions {
filename?: string;
}

export interface WebpackPlugin {
new (options?: WebpackPluginOptions): Plugin;
}
15 changes: 15 additions & 0 deletions packages/vue-server-renderer/types/test.ts
@@ -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 '../';

Expand Down Expand Up @@ -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'
})
]
});

0 comments on commit a67b795

Please sign in to comment.