Launch Week Day 3: Introducing Organization Notifications in Socket.Learn More
Socket
Book a DemoSign in
Socket

gulp-vuejs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-vuejs - npm Package Compare versions

Comparing version
1.0.7
to
2.0.0
+7
-26
package.json
{
"name": "gulp-vuejs",
"version": "1.0.7",
"description": "Fast and uncomplicated .vue file compiler for Gulp.",
"version": "2.0.0",
"description": "",
"main": "index.js",

@@ -11,29 +11,10 @@ "scripts": {

"type": "git",
"url": "git+https://github.com/wearespindle/gulp-vue.git"
"url": "git+https://github.com/npm/deprecate-holder.git"
},
"keywords": [
"vue"
],
"files": [
"LICENSE",
"README.md",
"index.js"
],
"author": "Devhouse Spindle",
"license": "MIT",
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/wearespindle/gulp-vue/issues"
"url": "https://github.com/npm/deprecate-holder/issues"
},
"homepage": "https://github.com/wearespindle/gulp-vue#readme",
"dependencies": {
"vue-template-compiler": "^2.2.6",
"concat-with-sourcemaps": "^0.1.6",
"event-stream": "^3.1.7",
"gulp-concat-util": "^0.5.1",
"gulp-util": "^3.0.2",
"lodash": "^2.4.1",
"lodash.assign": "^2.4.1",
"lodash.bind": "^2.4.1",
"through2": "^0.6.3"
}
"homepage": "https://github.com/npm/deprecate-holder#readme"
}

@@ -1,39 +0,5 @@

# gulp-vue
Simple and fast .vue template compiler for Gulp. Compiles all templates to an
object. Template namespace is configurable and filled dynamically based on your
template app structure. Intentionally no inline stylesheets and javascript.
# Deprecated Package
# Install and usage
Install like:
This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name.
npm install gulp-vuejs --save-dev
Make a templates directory and optionally subdirectories to use template
prefixes, e.g. `templates/mymodule`:
Then use it in your gulp file like:
const vue = require('gulp-vue')
gulp.task('templates', 'Build Vue templates', () => {
gulp.src('./src/templates/**/*.vue')
.pipe(vue('templates.js', {
prefixStart: 'templates',
commonjs: false,
}))
.on('error', notify.onError('Error: <%= error.message %>'))
.pipe(ifElse(PRODUCTION, () => uglify()))
.on('end', () => {
if (!PRODUCTION) del(path.join(BUILD_DIR, 'templates.js.gz'), {force: true})
})
.pipe(gulp.dest(BUILD_DIR))
.pipe(size(extend({title: 'templates'}, sizeConfig)))
.pipe(ifElse(PRODUCTION, () => gzip(gzipConfig)))
.pipe(ifElse(PRODUCTION, () => gulp.dest(BUILD_DIR)))
.pipe(size(extend({title: 'templates [gzip]'}, sizeConfig)))
.pipe(ifElse(isWatching, livereload))
})
This will generate a Javascript file, where templates are accessible from
`window.templates`. You can optionally use the `commonjs` option to generate a
module, which you can require in your code if you want to keep the templates
within a predefined namespace and part of an existing browserify entry.
Please contact support@npmjs.com if you have questions about this package.
'use strict'
const compiler = require('vue-template-compiler')
const Buffer = require('buffer').Buffer
const Concat = require('concat-with-sourcemaps')
const extend = require('lodash.assign')
const os = require('os')
const path = require('path')
const through = require('through2')
const transpile = require('vue-template-es2015-compiler')
let defaults = {
sep: os.EOL,
es2015: true,
namespace: 'window.templates',
extension: '.vue',
commonjs: false,
prefixStart: '',
prefixIgnore: [],
vue: {
preserveWhitespace: false,
},
}
function gulpVue(name, config) {
let options = extend({}, defaults, config || {})
/**
* Adds a render function to the render output code.
* When the es2015 option is set, it will produce cleaner
* output that can be used with `is strict`.
* @param {String} code - The compiled code.
* @returns {String} - The final javascript template code.
*/
function toFunction(code) {
let output = `function r(){${code}}`
if (options.es2015) return transpile(output)
return output
}
let concat, fileName, firstFile, templateNamespace
if (options.commonjs) {
templateNamespace = ''
} else templateNamespace = `${options.namespace}={}`
function combineFiles(file, encoding, next) {
if (!firstFile) {
firstFile = file
// Default path to first file basename.
fileName = name || path.basename(file.path)
concat = new Concat(!!file.sourceMap, fileName, options.sep)
concat.add(file.relative, templateNamespace, file.sourceMap)
}
// Replace hyphens with underscores in order to keep dot-notation.
let baseName = path.basename(file.path, options.extension).replace('-', '_')
let templateData = file.contents.toString('utf8')
try {
let _path = file.path.split('/')
let pathPrefixIndex = _path.indexOf(options.prefixStart)
if (pathPrefixIndex === -1) throw 'Cannot find prefix start!'
let templatePrefix = _path.slice(pathPrefixIndex + 1, _path.length - 1)
// Ignore path components from prefixIgnore.
templatePrefix = templatePrefix.filter((i) => {
return !options.prefixIgnore.includes(i)
})
let templateName = `${templatePrefix.join('_')}_${baseName}`
let compiled = compiler.compile(templateData, options.vue)
compiled.errors.forEach((msg) => {
this.emit('error', new Error(msg))
})
// Generate a javascript file for direct usage in the browser,
// using a global namespace.
let jsTemplate
if (options.commonjs) {
jsTemplate = `module.exports.${templateName}={render:${toFunction(compiled.render, options)}`
if (compiled.staticRenderFns.length) {
jsTemplate += `,staticRenderFns:[${compiled.staticRenderFns.map(toFunction).join(',')}]}`
} else jsTemplate += '}'
} else {
// Generate a commonjs module.
jsTemplate = `${options.namespace}.${templateName}={r:${toFunction(compiled.render, options)}`
if (compiled.staticRenderFns.length) {
jsTemplate += `,s:[${compiled.staticRenderFns.map(toFunction).join(',')}]}`
} else jsTemplate += '}'
}
concat.add(file.relative, jsTemplate, file.sourceMap)
} catch (_error) {
this.emit('error', new Error(_error))
}
next()
}
function flush(next) {
if (firstFile) {
let joinedFile = firstFile.clone()
joinedFile.path = path.join(options.cwd || firstFile.base, fileName)
joinedFile.base = options.base || firstFile.base
joinedFile.contents = new Buffer(concat.content)
this.push(joinedFile)
}
next()
}
return through.obj(combineFiles, flush)
}
module.exports = gulpVue
MIT License
Copyright (c) 2017 Spindle
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.