Git Product home page Git Product logo

vueify's Introduction

THIS REPOSITORY IS DEPRECATED

Note: We are concentrating our efforts on supporting webpack and rollup.

vueify Build Status npm version

Browserify transform for Vue.js components, with scoped CSS and component hot-reloading.

NOTE: master branch now hosts version ^9.0, which only works with Vue ^2.0. Vueify 8.x which works with Vue 1.x is in the 8.x branch.

This transform allows you to write your components in this format:

// app.vue
<style>
  .red {
    color: #f00;
  }
</style>

<template>
  <h1 class="red">{{msg}}</h1>
</template>

<script>
export default {
  data () {
    return {
      msg: 'Hello world!'
    }
  }
}
</script>

You can also mix preprocessor languages in the component file:

// app.vue
<style lang="stylus">
.red
  color #f00
</style>

<template lang="jade">
h1(class="red") {{msg}}
</template>

<script lang="coffee">
module.exports =
  data: ->
    msg: 'Hello world!'
</script>

And you can import using the src attribute:

<style lang="stylus" src="style.styl"></style>

Under the hood, the transform will:

  • extract the styles, compile them and insert them with the insert-css module.
  • extract the template, compile it and add it to your exported options.

You can require() other stuff in the <script> as usual. Note that for CSS-preprocessor @imports, the path should be relative to your project root directory. Starting in 7.0.0, @import in LESS, SASS and Stylus files can be either relative to your build tool root working directory, or to the file being edited. Or one can set import paths in options.

Usage

npm install vueify --save-dev
browserify -t vueify -e src/main.js -o build/build.js

And this is all you need to do in your main entry file:

// main.js
var Vue = require('vue')
var App = require('./app.vue')

new Vue({
  el: '#app',
  render: function (createElement) {
    return createElement(App)
  }
})

In your HTML:

<body>
  <div id="app"></div>
  <script src="build.js"></script>
</body>

If you are using vueify in Node:

var fs = require("fs")
var browserify = require('browserify')
var vueify = require('vueify')

browserify('./main.js')
  .transform(vueify)
  .bundle()
  .pipe(fs.createWriteStream("bundle.js"))

Building for Production

Make sure to have the NODE_ENV environment variable set to "production" when building for production! This strips away unnecessary code (e.g. hot-reload) for smaller bundle size.

If you are using Gulp, note that gulp --production does not affect vueify; you still need to explicitly set NODE_ENV=production.

ES2015 with Babel

Vueify is pre-configured to work with Babel. Simply install Babel-related dependencies:

npm install\
  babel-core\
  babel-preset-es2015\
  --save-dev

Then create a .babelrc:

{
  "presets": ["es2015"]
}

And voila! You can now write ES2015 in your *.vue files. Note if you want to use ES2015 on normal *.js files, you will also need babelify.

You can also configure babel with the babel field in vue.config.js, which will take the highest priority.

Enabling Other Pre-Processors

For other pre-processors, you also need to install the corresponding node modules to enable the compilation. e.g. to get stylus compiled in your Vue components, do npm install stylus --save-dev.

These are the preprocessors supported by vueify out of the box:

PostCSS

Vueify uses PostCSS for scoped CSS rewrite. You can also provide your own PostCSS plugins! See config section below for an example.

Configuring Options

Create a vue.config.js file at where your build command is run (usually the root level of your project):

module.exports = {
  // configure a built-in compiler
  sass: {
    includePaths: [...]
  },
  // provide your own postcss plugins
  postcss: [...],
  // register custom compilers
  customCompilers: {
    // for tags with lang="ts"
    ts: function (content, cb, compiler, filePath) {
      // content:  content extracted from lang="ts" blocks
      // cb:       the callback to call when you're done compiling
      // compiler: the vueify compiler instance
      // filePath: the path for the file being compiled
      //
      // compile some TypeScript... and when you're done:
      cb(null, result)
    }
  }
}

Example using custom PostCSS plugin:

var cssnext = require('cssnext')

module.exports = {
  postcss: [cssnext()]
}

Alternatively, if you are using vueify in Node and don't want to create a vue.config.js file:

var fs = require("fs")
var browserify = require('browserify')
var vueify = require('vueify')

// apply custom config
vueify.compiler.applyConfig({
  // ...same as in vue.config.js
})

browserify('./main.js')
  .transform(vueify)
  .bundle()
  .pipe(fs.createWriteStream("bundle.js"))

Or simply pass configuration object to vueify (in Node) (for instance to set sass search paths as in the following example):

var fs = require("fs")
var browserify = require('browserify')
var vueify = require('vueify')

browserify('./main.js')
  .transform(vueify, {
    sass: {
      includePaths: [...]
    },
    // ...same as in vue.config.js
  })
  .bundle()
  .pipe(fs.createWriteStream("bundle.js"))

Scoped CSS

When a <style> tag has the scoped attribute, its CSS will apply to elements of the current component only. This is similar to the style encapsulation found in Shadow DOM, but doesn't require any polyfills. It is achieved by transforming the following:

<style scoped>
.example {
  color: red;
}
</style>
<template>
  <div class="example">hi</div>
</template>

Into the following:

<style>
.example[_v-1] {
  color: red;
}
</style>
<template>
  <div class="example" _v-1>hi</div>
</template>

Scoped CSS Notes

  1. You can include both scoped and non-scoped styles in the same component.

  2. The following will be affected by both the parent's scoped CSS and the child's scoped CSS:

  • A child component's root node
  • Content inserted to a child component via <slot>

Hot Reload

To enable hot component reloading, you need to install the browserify-hmr plugin:

npm install browserify-hmr --save-dev
watchify -p browserify-hmr index.js -o bundle.js

You can scaffold a hot-reload enabled project easily using vue-cli and the this template.

CSS Extraction

By default, the CSS in each component is injected into the page using a <style> tag. This works well in most scenarios and enables CSS hot-reloading during development. However, in some cases you may prefer extracting all component CSS into a single file for better performance. To do that, you will need to add the CSS extraction browserify plugin.

Via CLI:

browserify -t vueify -p [ vueify/plugins/extract-css -o dist/bundle.css ] main.js

Via API:

browserify('./main.js')
  .transform('vueify')
  .plugin('vueify/plugins/extract-css', {
    out: 'dist/bundle.css' // can also be a WritableStream
  })
  .bundle()

This only works for vueify 9+. For Vue 1.x / vueify 8.x you can use vueify-extract-css.

Building for Production

When building for production, follow these steps to ensure smaller bundle size:

  1. Make sure process.env.NODE_ENV === "production". This tells vueify to avoid including hot-reload related code.

  2. Apply a global envify transform to your bundle. This allows the minifier to strip out all the warnings in Vue's source code wrapped in env variable conditional blocks.

Compiler API

The compiler API (originally vue-component-compiler) is also exposed:

var compiler = require('vueify').compiler

// filePath should be an absolute path
compiler.compile(fileContent, filePath, function (err, result) {
  // result is a common js module string
})

Syntax Highlighting

Currently there are syntax highlighting support for Sublime Text, Atom, Vim, Visual Studio Code and Brackets. Contributions for other editors/IDEs are highly appreciated! If you are not using any pre-processors in Vue components, you can also get by by treating *.vue files as HTML in your editor.

Changelog

Please see the Releases page for changes in versions ^9.0.0.

License

MIT

vueify's People

Contributors

adamniederer avatar balping avatar cheapsteak avatar crookedneighbor avatar danieldiekmeier avatar dhcmrlchtdj avatar gzzhanghao avatar hanachin avatar itsmapleleaf avatar kazupon avatar linusborg avatar losadaem avatar martinduparc avatar mattdesl avatar mgrinspan avatar mysticatea avatar paulpflug avatar unidwell avatar yyx990803 avatar zigomir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vueify's Issues

Emitting errors through the browserify transform

So this might be a long shot and may not be related to Vueify, BUT I usually get errors in the console for the rest of the stack so here it goes.

I'm using a gulp task with browserify:

gulp.task('js', () => {
  return browserify(paths.app)
    .transform('babelify')
    .transform('vueify')
    .bundle()
    .pipe(source('app.js'))
    .pipe(convertStream())
    .pipe(sourcemaps.init())
    .pipe(sourcemaps.write())
    // When not in dev minify the JS (also removes source maps)
    .pipe(gulpif(!envIsDev, uglify()))
    .pipe(gulp.dest(paths.dist))
    .pipe(browserSync.stream())
})

This works really well with your example on how to run Vueify + Browserify + Node (in this case gulp). However, I made a dumb and funny mistake in my app.vue. I had put exports {} not export {}. I would expect some build/compile error, but instead the task sits at Starting 'js'... and never finishes.

Implementing Autoprefixer

Would you have any objection to running autoprefixer on all CSS going through Vueify? If not, would an attribute on the style tag work? Something like <style lang="sass" autoprefix>. Autoprefixer seems fast enough that we can run it on everything going through and be all right.

I'm currently getting it done by creating my own sass register in vue.config.js but if I wanted to use something else I'd need to make additional ones. Here's my current workaround.

// Giving Sass some Autoprefixer love...

var sass = require('node-sass');
var autoprefixer = require('autoprefixer');
var postcss = require('postcss');

module.exports = function(compiler) {
  compiler.register({
    lang: 'scss',
    type: 'style',
    compile: function(content, cb) {
      sass.render({
        data: content
      }, function (err, res) {
        if (err) {
          cb(err);
        } else {
          var css = res.css.toString();
          var prefixed = postcss([autoprefixer]).process(css);
          cb(null, prefixed);
        }
      });
    }
  });
};

Let me know if you're all right with either of these ideas or know of a better approach and I'll get you a pull request.

Node version

Hi all,

Where can i see what Node version Vueify requires?

on node v4.2.1 it fails with

'browserify' errored after 420 ms
Error: Cannot find module 'vueify'

import in Stylus

Hi !

I want to @import in Stylus, but i have this strange error :

Browserify Failed!: Why.vue:undefined:undefined
Cannot read property 'nodeName' of undefined

I'm using vueify via Laravel-elixir-vueify, and i have the last version > 7

When i try with sass everything is good

// work
<style lang="sass">
    @import './resources/assets/sass/config/settings'
</style>
// don't work
<style lang="stylus">
    @import './resources/assets/stylus/config/Settings'
</style>

Any idea ?

Add usage for npm v3

In Usage section on README.md:

npm install vueify --save-dev
browserify -t vueify -e src/main.js -o build/build.js

In npm v3, it will be:

npm install vueify vueify-insert-css babel-runtime babel-preset-es2015 babel-plugin-transform-runtime vue-hot-reload-api --save-dev
browserify -t vueify -e src/main.js -o build/build.js

Is this correct?

Inject css like the js

Hi !

It could be great to inject the CSS in a .vue file into the global CSS file,
Like the js.

By now the CSS is injected into the head

screen shot 2015-11-20 at 08 19 36

Thanks !

Can I include a Vue directive inside my .vue file?

Is there a way I can include a directive inside my SomeComponent.vue file? It's a directive used only for that component. I tried including it inside the script tags outside the export default { ... } but it doesn't seem to work.

Relative paths in less imports don't work

I'm having issues with importing external less files into styling parts of a .vue component file. I noticed that the README for vueify says Note that for CSS-preprocessor @imports, the path should be relative to your project root directory.

My problem is that my .vue file exists in a npm package (along with some LESS that I want to import). This package is then distributed uncompiled and used in other projects where compilation with browserify is performed, which means that the project root directory cannot be predicted when developing the npm package.

Is there any way I can get around this?

Vueify leaves full paths

Hi,

How can I remove full paths from bundled JS file? Browserify has an option for this called opts.fullPaths but it doesn't seem to have any influence on vueify... so I have full paths in my bundle.js in each if (module.hot) section like:

...
if (module.hot) {
    (function () {
        module.hot.accept()
        var hotAPI = require("vue-hot-reload-api")
        hotAPI.install(require("vue"), true)
        if (!hotAPI.compatible) 
            return
            var id = "/Users/od/project/resources/assets/js/components/channelsList.vue"
        if (!module.hot.data) {
            hotAPI.createRecord(id, module.exports)
        } else {
            hotAPI.update(id, module.exports, module.exports.template)
        }
    })()
}
...

Maybe I can just turn off hot reload feature?

Thanks.

When .scss file is empty, the compilation does not finish.

And it doesn't throw any errors.
I'm not familiar with browserify and even node stream but after I inserted the follow code, at the line 7 in "vue-component-compiler/compilers/sass.js", it worked fine.:baby_chick:

if(raw === ''){ 
  cb(null, ''); 
}

process.env.NODE_ENV = 'production' causes a type error

I have a .vue file
Example:

<template>
    <div class="address-fields">
        <input type="text" placeholder="Venue Name" v-model="address.venue">
        <input type="text" placeholder="Address 1" v-model="address.street_1">
        <input type="text" placeholder="Address 2" v-model="address.street_2">
        <input type="text" placeholder="City" v-model="address.city">
        <input type="text" placeholder="State" v-model="address.state" maxlength="2">
        <input type="text" placeholder="ZIP/Postal" v-model="address.postal_code">
        <input type="text" placeholder="Country" v-model="address.country" maxlength="2">
    </div>
</template>

<script>
    export default{
       props: {
            date: Object
       },
       events: {
            autocompleteAddress: function(name, place) {
                this.autocomplete(name,place);
            }
       },
       methods:{
            autocomplete:function (name, place) {
                var mapper = {
                    route: 'street_1',
                    locality: 'city',
                    administrative_area_level_1: 'state',
                    country: 'country',
                    postal_code: 'postal_code'
                };
                for ( var i = 0; i < place.length; i++ ) {
                    var type = place[i].types[0];
                    var val = place[i][componentForm[type]];

                    if (type == 'route') {
                        val = name;
                    }

                    this.address[mapper[type]] = val;
                }
            }
       }
   }
</script>

and running gulp without the being set to production it runs fine.
But making it to production mode i get:
TypeError: Cannot read property 'minify' of undefined while parsing file.

Sass lang support

Hey!

Right now only scss syntax is supported, and the following results in error:

button 
    padding: 10px 20px
    font-family: "Consolas", monospace
Error: Invalid CSS after "": expected 1 selector or at-rule, was "button" while parsing file: path/to/vue-project/src/components/random.vue

I like jade + sass, is there a way to write sass?
Thanks!

Jade options

In working to get set up with vueify, I've hit a snag when trying to pass options into jade. I wanted to be able to include a file in jade in a component (for mixins), and that requires setting a filename (for relative paths) or basedir option when calling jade.compile.

I set up my vue.config.js to pass in the option:

{
  jade: {
    basedir: __dirname
  }
}

But the error I was getting during compilation was unchanged.

After some investigation, it looks like there's a small error in where the options are getting passed into jade.compile:

var html = jade.compile(raw)(options.jade || {})

If I pass in the options to the initial call of jade.compile, everything seems great:

var html = jade.compile(raw, options.jade || {})()

If I'm correct (never a given) and you'd like me to submit a PR, I'd be happy to do so: I wasn't sure if it'd be overkill for a one-liner.

Finally: thanks for all your work on this! I heard your excellent appearance on JavaScript Jabber and have really been enjoying diving into the vue.js world.

warning: possible EventEmitter memory leak detected.

I'm getting this warning after update to the last version.

(node) warning: possible EventEmitter memory leak detected. 11 dependency listeners added. Use emitter.setMaxListeners() to increase limit.
  Trace
at EventEmitter.addListener (events.js:239:17)
at Stream.end (.../node_modules/vueify/index.js:21:14)
at _end (.../node_modules/through/index.js:65:9)
at Stream.stream.end (.../node_modules/through/index.js:74:5)
at DestroyableTransform.onend (.../node_modules/readable-stream/lib/_stream_readable.js:545:10)
at DestroyableTransform.g (events.js:260:16)
at emitNone (events.js:72:20)
at DestroyableTransform.emit (events.js:166:7)
at endReadableNT (.../node_modules/readable-stream/lib/_stream_readable.js:960:12)
at nextTickCallbackWith2Args (node.js:455:9)
at process._tickCallback (node.js:369:17)

Error with sass persists...

/media/.../node_modules/vueify/node_modules/vue-component-compiler/compilers/sass.js:13
        cb(null, css) // compat for node-sass < 2.0.0
                 ^
ReferenceError: css is not defined
    at sass.render.success (/media/.../node_modules/vueify/node_modules/vue-component-compiler/compilers/sass.js:13:18)
    at onSuccess (/media/.../node_modules/node-sass/sass.js:91:18)
...

I see an issue closed about node-sass but i have already updated the packages and still im getting this error.

Huge files!

I just made a "Hello World component", nothing fency.
I compiled it down using gulp, browserify and vueify.
Then I saw that the resulting *.js file is over 10.000 lines long.
If I compress/minify it, it's still over 250kb which I find a lot for a *.js file.
I love the idea of vueify and I dont want to blindly complain on this. But do you have any thoghts on that?

Vueify problem with vue hot reload.

Currently using vueify with laravel elixir and i'm running into an issue.
Now it compiles the .vue file just fine and produces what i need, but it appends an vue-hot-reload-api into the production file....

Is that always necessary? can it just process the .vue component and produce the js file without the vue-hot-reload-api included in the JS?

I cant seem to find a way to get rid of it.

Thanks.

Error when using node-sass?

/Users/.../node_modules/vueify/node_modules/vue-component-compiler/node_modules/clean-css/lib/imports/inliner.js:154
      firstContentIdx = data.indexOf('{', firstContentIdx + 1);
                             ^
TypeError: Object #<Object> has no method 'indexOf'
  at Inliner.contentScanner (/Users/kalasoo/Projects/coder-price/node_modules/vueify/node_modules/vue-component-compiler/node_modules/clean-css/lib/imports/inliner.js:154:30)
  at Object.Inliner.process (/Users/kalasoo/Projects/coder-price/node_modules/vueify/node_modules/vue-component-compiler/node_modules/clean-css/lib/imports/inliner.js:44:24)
  at /Users/kalasoo/Projects/coder-price/node_modules/vueify/node_modules/vue-component-compiler/node_modules/clean-css/lib/clean.js:65:63
  at runner (/Users/kalasoo/Projects/coder-price/node_modules/vueify/node_modules/vue-component-compiler/node_modules/clean-css/lib/clean.js:62:35)
  at CleanCSS.minify (/Users/kalasoo/Projects/coder-price/node_modules/vueify/node_modules/vue-component-compiler/node_modules/clean-css/lib/clean.js:64:12)
  at /Users/kalasoo/Projects/coder-price/node_modules/vueify/node_modules/vue-component-compiler/index.js:71:27
  at /Users/kalasoo/Projects/coder-price/node_modules/vueify/node_modules/vue-component-compiler/node_modules/async/lib/async.js:254:17
  at done (/Users/kalasoo/Projects/coder-price/node_modules/vueify/node_modules/vue-component-compiler/node_modules/async/lib/async.js:135:19)
  at /Users/kalasoo/Projects/coder-price/node_modules/vueify/node_modules/vue-component-compiler/node_modules/async/lib/async.js:32:16
  at /Users/kalasoo/Projects/coder-price/node_modules/vueify/node_modules/vue-component-compiler/node_modules/async/lib/async.js:251:21
  at /Users/kalasoo/Projects/coder-price/node_modules/vueify/node_modules/vue-component-compiler/node_modules/async/lib/async.js:575:34
  at /Users/kalasoo/Projects/coder-price/node_modules/vueify/node_modules/vue-component-compiler/index.js:38:13
  at sass.render.success (/Users/kalasoo/Projects/coder-price/node_modules/vueify/node_modules/vue-component-compiler/compilers/sass.js:10:7)
  at options.success (/Users/kalasoo/Projects/coder-price/node_modules/node-sass/lib/index.js:169:7)

This error happens when sass is used.

v-bind:class=does not work!!

in template: v-bind:class="{ hide:cookieSet,dismiss : dismissCookie} "

it does not work properly with my data

 data : () => {
    /**
    * @param {string} cookieName
    * @param {message} cookieName
    * @param {expiresIn} cookieName
    */
      return {
        cookieName : 'fileManager',
        message : 'We use cookies to ensure that we give you the best experience on our website. By clicking on the close icon(X), you are agreeing to allowing my site to use 3rd party cookies.',
        expiresIn : 365,
        cookieSet : false,
        dismissCookie : false
      }
  },

Vueify seems to remove input type attribute

When I set NODE_ENV=production my input type attribute disappear. Am I doing something wrong?

"vue-hot-reload-api": "^1.2.2",
"vueify": "^8.1.1",
"vueify-insert-css": "^1.0.0"
"gulp": "^3.8.8",
"babel-core": "^6.3.26",
"babel-plugin-transform-runtime": "^6.3.13",
"babel-preset-es2015": "^6.3.13",
"babel-preset-stage-2": "^6.3.13",
"babel-runtime": "^5.8.34",

Webpack related: vuejs/vue-loader#33

Before:

<input type="text" name="something" class="form-control" v-model="something">

After:

<input name=something class=form-control v-model=something>

Hangs

Hello , i´m having a problem
after a while, after saving my vue compoents the output build.js does not get created.I dont see any error in the npm run dev console.

The browser hangs waiting for the build.js .
If i reboot the pc it works ok and after a while it eventually happen again.

Do you know any solution ?
i´m using windows 7, nodejs 0.12.4

remove dependency of vue?

When using browserify + vueify, it requires vue to be installed beforehand (although not specified in package.json in this repo), if not, the following error will show up when building.

Error: Cannot find module 'vue' from '/path/to/project/script/dir/'

Actually in our project, we include vue.js using html script tag and host on cdn server, while the app.min.js hosted in our own static server, so it's no use to bundle vue.js in again.

But from lib/compiler.js, the dependency of vue seems hardcoded in, and there is no chance to remove vue.

Any suggestions?

Thanks.

Improve support for watchify when using preprocessors

Currently vueify don't emit dependency files on preprocessors compilation. For example, when importing files in sass styles.
Because of this watchify can't rebuild or cache changes based on these dependencies.

I've created a pull request #23 to show a quick implementation that I was using for testing. It would be nice to have this implemented.

Thanks for vueify, it is working really well with hot-reloading!

Minifying templates during compilation

One issue I've been having is that there doesn't seem to be a way for me to minify template code before it gets bundled up. This results in a larger bundle size because of the unneeded newlines and tabs. Would it be possible to add an entry point for minifying templates before they get bundled?

Why useless codes are packaged?

when i use gulp + browserify, also with vueify, once i run gulp build-js, many useless codes are packaged. they are almost more than 70kb. When i view the packaged code, which has the logic of browserify-hmr processing.
How can i remove them ?

HMR for root component

Hey, I'm trying to get the following case working.

I have a file like this which just starts a basic Vue app with a single component:

index.js

var Vue = require('vue');
var Component = Vue.extend(require('./component.vue'));
new Component({ el: 'body', replace: false });

And my component:

component.vue

<style scoped>
  h2 { color: #f66; }
</style>
<template>
  <h2>{{msg}}</h2>
</template>
<script>
export default {
  data () {
    return {
      msg: 'hello!'
    }
  }
}
</script>

Now I can do the following with budo to get things running quickly:

budo index.js --open -- -t vueify -p browserify-hmr

HMR is emitting updates but only changes to <style> are getting hot-reloaded. The<template> is not updated until hard reloading the browser page.

Adding Lost grid framework for postcss

For some resason I can't get the lost grid framework to work with postcss. Here is my vue config file:

var postStylus = require('poststylus');

module.exports = {
  postcss: [postStylus(['lost'])]
}

Error:

TypeError: Cannot read property 'filename' of undefined
    at /Users/rweas/Projects/Frontline/node_modules/poststylus/index.js:31:33
    at LazyResult.run (/Users/rweas/Projects/Frontline/node_modules/vueify/node_modules/postcss/lib/lazy-result.js:201:20)
    at /Users/rweas/Projects/Frontline/node_modules/vueify/node_modules/postcss/lib/lazy-result.js:115:37
    at LazyResult.asyncTick (/Users/rweas/Projects/Frontline/node_modules/vueify/node_modules/postcss/lib/lazy-result.js:129:15)
    at processing.Promise.then._this2.processed (/Users/rweas/Projects/Frontline/node_modules/vueify/node_modules/postcss/lib/lazy-result.js:155:20)
    at lib$es6$promise$$internal$$initializePromise (/Users/rweas/Projects/Frontline/node_modules/vueify/node_modules/es6-promise/dist/es6-promise.js:373:9)
    at new lib$es6$promise$promise$$Promise (/Users/rweas/Projects/Frontline/node_modules/vueify/node_modules/es6-promise/dist/es6-promise.js:664:9)
    at LazyResult.async (/Users/rweas/Projects/Frontline/node_modules/vueify/node_modules/postcss/lib/lazy-result.js:152:27)
    at LazyResult.then (/Users/rweas/Projects/Frontline/node_modules/vueify/node_modules/postcss/lib/lazy-result.js:75:21)
    at module.exports (/Users/rweas/Projects/Frontline/node_modules/vueify/lib/style-rewriter.js:66:8)
[12:10:48] gulp-notify: [Laravel Elixir] Browserify Failed!: Cannot read property 'filename' of undefined while parsing file: /Users/rweas/Projects/Frontline/resources/assets/js/components/Bar.vue

It does work with just normal stylus though.

Incorrect build of the vuejs project

Hi,

I've met an issue, which is described here.

To reproduce it, I've created the jsbin:
http://jsbin.com/rutuka/edit?html,js,output

However, if I assemble all the components manually - everything is working.

So I have only one assumption, for some reason, vueify or browserify is messing up with the code during the assembling.

I've made the project public, so you can reproduce:
https://github.com/PavelPolyakov/twiliocms

How to install:

git clone [email protected]:PavelPolyakov/twiliocms.git .
npm i
bower i
npm run build
gulp serve

open localhost:3000, do the thing from video http://monosnap.com/file/L0Yup4PNZ2FTkeQD4eWdAWqmDWmPPl .

I hope you see it doesn't work, while it works on jsbin.

vueify produced code works differently then pure Vue code

Hi,

Another issue from my side. Using the latest Vue (1.0.0-rc.1).

Short description - when I pass an object of the array to the other component, then change it there - changes do reflect the original array if I use pure Vue, changes does not reflect the original array if I use the code which is generated by vueify. I know that there are caveats when watch to track Array changes, spent some time to track the issue down: http://forum.vuejs.org/topic/119/is-there-a-pretty-way-to-update-object-in-array .

Here is the repository I have prepared, which allows to reproduce the issue:
https://github.com/PavelPolyakov/vue-vs-vueify-issue

Here are the links to test it online:
pure - http://pavelpolyakov.com/vue-vs-vueify-issue/pure/
version which was built by vueify - http://pavelpolyakov.com/vue-vs-vueify-issue/vueify/

Video (not very informative, but helps to understand the issue):
pure - https://monosnap.com/file/krXkR4yp2gYE7ZyQC5m0s9dOYHv5Fm
vueify - https://monosnap.com/file/qF5Xb1diQzbrsQD8X3olV6nIiUE5pB

Any thoughts how the code (which would be processed by vueify) should be updated?

Please, let me know if there is anything I can help with this issue. E.g. provide some additional information.

upd.
don't know if it's important, but I have tried to do the same with vue-loader and webpack, the result is the same - pure version works, generated version doesn't.

Regards,

Import stylus plugins for all components

How can I import stylus plugins for all components? I understand I can do the following in each component:

<style lang="stylus" scoped>
  @import "nib"
  @import "jeet"
  // ...
</style>

But is there a way to import nib and jeet for all components? I tried in vue.config.js:

var nib = require('nib')
var jeet = require('jeet')

module.exports = {
  stylus: {
    use: [nib(), jeet()]
    import: ['nib', 'jeet']
  }
}

While use works (I can use the plugins importing them manually from each component), the imports don't work and I can't use any of the features provided by those plugins.

What am I missing?

Ready method not being called

Using coffee script and jade btw
I'm using the component is tag, and it's displaying the view fine, and calling methods in the component on button clicks and showing data, but the one thing that won't work is the ready method. I set it to
console.log 'hello world' but it's not doing anything

<script lang="coffee">
module.exports =
    ready: () ->
            @foo = 'not foobar, something else!'
            console.log 'Im being called'

    data: () ->
        ret = 
            foo: 'foobar'
</script>

<template lang="jade">
{{foo}}
</template>

When referred es6 file refers other es6 files, an error occurs.

app.vue

<style lang="sass" src="./styles/app.scss"></style>
<script lang="es6" src="./js/app.js"></script>
<template>
</template>

app.js

import A from './A';
module.exports = {};

A.js

import B from './B';
export default class A {}

In this case, an error occurs at A.js like the below message.

'import' and 'export' may appear only with 'sourceType: module'

I think this is because A.js is not compiled to es5, so browserify throws the error.
I know this is solved by using babelify. But I would like to know if this is an expected behavior.

Less Preproccessor Async

Sorry, I'm new to Git and the standard process for submitting issues. I'm using Vueify with less 2.0.0 and the less.js compiler is returning unidentified for the CSS return value. Placing console.log statements inside the render callback and just prior to the return indicate the render is Async. Just thought I would mention it.

Scoped styles for partials?

Hey I was hoping to add scoped styles to a partial I am using in one of my components. The use case would be - I am using partials for svgs that may get shared amongst components but I would like their presentation to scoped to the individual component. I understand that I can use non-scoped styles in combination with scoped styles (and scope the css via selectors) but I would love if I could have everything in one .less file. Just wondering if there is a reason that I am not aware of.

Error when parsing 1.0.alpha syntax

I get this error when I tried run gulp with the new alpha syntax:

..../node_modules/vueify/node_modules/vue-component-compiler/node_modules/html-minifier/dist/htmlminifier.js:301 throw 'Parse Error: ' + html; ^ Parse Error: <button :@click="displayConnexionFields" class="button__outline">Connexion</button>

I guess it's the : symbol which causes the problem

Scoped styles with sass

Hi!

Im evaluating Vue.js for a new project, and the vueify component style of building apps feels good. However im going to be using sass, and noticed scoping does not work when nesting in sass.

This does not make the style scoped

<style lang="sass" scoped>
  .component {
    h3 {
      color: blue;
    }
  }
</style>

... But this does work.

<style lang="sass" scoped>
  .component h3 {
      color: blue;
  }
</style>

Is this intentional or a bug?

jsdoc3?

Not really an issue, just a question.
Is anyone using jsdoc3 on .vue files?

edit: seems jsdoc3 can not parse es6 currently so I guess that settles it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.