Skip to content
This repository has been archived by the owner on Dec 26, 2018. It is now read-only.

Non compiled #102

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,27 @@ These are the preprocessors supported by vueify out of the box:
- pug
- coffee-script (use `coffee` in [config section](#configuring-options))

## Building for modern browsers

If you're developing for modern browsers and you don't need to transpile your code you can use `noncompiled` value in lang attribute.
Just make sure to use `commonjs` module syntax:

``` vue
<template>
<h2>{{msg}}</h2>
</template>

<script>
module.exports = {
data () {
return {
msg: 'Non Compiled Component!'
}
}
}
</script>
```

## PostCSS

Vueify uses PostCSS for scoped CSS rewrite. You can also provide your own PostCSS plugins! See [config section](#configuring-options) below for an example.
Expand Down
24 changes: 12 additions & 12 deletions lib/compilers/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ function getBabelRc () {
return rc
}

if (babelOptions === defaultBabelOptions) {
try {
ensureRequire('babel', ['babel-preset-es2015', 'babel-runtime', 'babel-plugin-transform-runtime'])
} catch (e) {
console.error(e.message)
console.error(
'\n^^^ You are seeing this because you are using Vueify\'s default babel ' +
'configuration. You can override this with .babelrc or the babel option ' +
'in vue.config.js.'
)
module.exports = function (raw, cb, compiler, filePath) {
if (babelOptions === defaultBabelOptions) {
try {
ensureRequire('babel', ['babel-preset-es2015', 'babel-runtime', 'babel-plugin-transform-runtime'])
} catch (e) {
console.error(e.message)
console.error(
'\n^^^ You are seeing this because you are using Vueify\'s default babel ' +
'configuration. You can override this with .babelrc or the babel option ' +
'in vue.config.js.'
)
}
}
}

module.exports = function (raw, cb, compiler, filePath) {
try {
var babel = require('babel-core')
var options = assign({
Expand Down
6 changes: 6 additions & 0 deletions lib/compilers/noncompiled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var ensureRequire = require('../ensure-require.js')

module.exports = function (raw, cb) {
ensureRequire('skip-compilers', [])
cb(null, raw)
}
13 changes: 13 additions & 0 deletions test/fixtures/noncompiled.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<h2>{{msg}}</h2>
</template>

<script>
module.exports = {
data () {
return {
msg: 'Hello from Non Compiled Component!'
}
}
}
</script>
2 changes: 1 addition & 1 deletion test/fixtures/script-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export default {
msg: 'Hello from Component A!'
}
}
};
}
6 changes: 6 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ describe('vueify', () => {
expect(style).to.contain('@media print {\n .foo[' + id + '] {\n color: #000;\n }\n}')
})

test('noncompiled', window => {
const module = window.vueModule
assertRenderFn(module, '<h2>{{msg}}</h2>')
expect(module.data().msg).to.contain('Hello from Non Compiled Component!')
})

testCssExtract('style-export', css => {
expect(css).to.equal('h2 {color: red;}')
})
Expand Down