Skip to content

Commit

Permalink
Add gobal ressource
Browse files Browse the repository at this point in the history
  • Loading branch information
do-web committed Mar 14, 2018
1 parent 3b32ec4 commit b46c71b
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/renderer/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 19,7 @@ const defaultOptions = {
link: [],
style: []
},
sassResources: '',
outputPath: '/tmp/vuexpress_ssr',
cssOutputPath: 'style.css',
publicPath: 'public',
Expand Down Expand Up @@ -195,8 196,8 @@ class Compiler {

return {
css: generateLoaders(),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass')
sass: generateLoaders('sass', { indentedSyntax: true, data: this.options.sassResources }),
scss: generateLoaders('sass', { data: this.options.sassResources })
};
}

Expand Down
4 changes: 4 additions & 0 deletions lib/renderer/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 15,8 @@ const defaultOptions = {
preCompile: [],
preCompileAll: true,
plugins: [],
mixins: [],
sassResources: '',
watch: false,
extractCSS: true,
cache: true,
Expand Down Expand Up @@ -50,6 52,7 @@ function rendererFactory(vOptions) {
watch: options.watch,
globals: options.globals,
outputPath: options.outputPath,
sassResources: options.sassResources,
cssOutputPath: options.cssOutputPath,
publicPath: options.publicPath,
cache: options.cache,
Expand All @@ -62,6 65,7 @@ function rendererFactory(vOptions) {
const rendererOptions = {
metaInfo: options.metaInfo,
plugins: options.plugins,
mixins: options.mixins,
preCompile: options.preCompile,
preCompileAll: options.preCompileAll,
globals: options.globals
Expand Down
4 changes: 4 additions & 0 deletions lib/renderer/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 26,7 @@ Vue.use(Vuex);
const defaultRendererOptions = {
metaInfo: Object.create(null),
plugins: [],
mixins: [],
preCompile: [],
preCompileAll: true,
globals: Object.create(null)
Expand All @@ -44,6 45,9 @@ class Renderer extends EventEmitter {
this.compiler = compiler;
this.vueRenderer = vueServerRenderer.createRenderer();
this.options = Object.assign({}, defaultRendererOptions, options);
this.options.mixins.forEach(mixin => {
Vue.mixin(mixin);
});
this.init();
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
{
"name": "@doweb/vuexpress",
"version": "1.0.9",
"version": "1.0.10",
"description": "Vue Express.js = VueXpress / A server side rendering engine for Express.js. Use .vue files as your express.js templates.",
"main": "lib/index.js",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 26,7 @@ const defaultOptions: CompilerOptions = {
link: [],
style: [],
},
sassResources: '',
outputPath: '/tmp/vuexpress_ssr',
cssOutputPath: 'style.css',
publicPath: 'public',
Expand Down Expand Up @@ -211,8 212,8 @@ class Compiler implements ICompiler {

return {
css: generateLoaders(),
sass: generateLoaders('sass', {indentedSyntax: true}),
scss: generateLoaders('sass'),
sass: generateLoaders('sass', {indentedSyntax: true, data: this.options.sassResources}),
scss: generateLoaders('sass', {data: this.options.sassResources}),
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/renderer/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 15,8 @@ const defaultOptions = {
preCompile: [],
preCompileAll: true,
plugins: [],
mixins: [],
sassResources: '',
watch: false,
extractCSS: true,
cache: true,
Expand Down Expand Up @@ -50,6 52,7 @@ function rendererFactory(vOptions?: VueRendererOptionParams): Renderer {
watch: options.watch,
globals: options.globals,
outputPath: options.outputPath,
sassResources: options.sassResources,
cssOutputPath: options.cssOutputPath,
publicPath: options.publicPath,
cache: options.cache,
Expand All @@ -62,6 65,7 @@ function rendererFactory(vOptions?: VueRendererOptionParams): Renderer {
const rendererOptions: RendererOptionParams = {
metaInfo: options.metaInfo,
plugins: options.plugins,
mixins: options.mixins,
preCompile: options.preCompile,
preCompileAll: options.preCompileAll,
globals: options.globals,
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 34,7 @@ Vue.use(Vuex);
const defaultRendererOptions: RendererOptions = {
metaInfo: Object.create(null),
plugins: [],
mixins: [],
preCompile: [],
preCompileAll: true,
globals: Object.create(null),
Expand All @@ -57,6 58,9 @@ class Renderer extends EventEmitter implements IRenderer {
this.compiler = compiler;
this.vueRenderer = vueServerRenderer.createRenderer();
this.options = Object.assign({}, defaultRendererOptions, options);
this.options.mixins.forEach((mixin)=>{
Vue.mixin(mixin);
});
this.init();
}

Expand Down
2 changes: 2 additions & 0 deletions src/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 4,7 @@ import typeof FileSystem from 'fs';
export type CompilerOptions = {
config: Object,
metaInfo: Object,
sassResources: string,
basePath: string,
watch: boolean,
cache: boolean,
Expand Down Expand Up @@ -45,6 46,7 @@ export type RendererOptions = {
export type RendererOptionParams = {
metaInfo?: Object,
plugins?: Array<string | Object>,
mixins?: Array<Object>,
preCompile?: Array<string>,
preCompileAll: boolean,
globals?: Object
Expand Down

0 comments on commit b46c71b

Please sign in to comment.