Skip to content

Commit af96700

Browse files
unidwellyyx990803
authored andcommitted
Added support for browserify transform options. (vuejs#89)
1 parent 7683c39 commit af96700

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Under the hood, the transform will:
5858
- extract the styles, compile them and insert them with the `insert-css` module.
5959
- extract the template, compile it and add it to your exported options.
6060

61-
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.
61+
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.
6262

6363
## Usage
6464

@@ -108,7 +108,7 @@ var fs = require("fs")
108108
var browserify = require('browserify')
109109
var vueify = require('vueify')
110110

111-
browserify('./entry.js')
111+
browserify('./main.js')
112112
.transform(vueify)
113113
.bundle()
114114
.pipe(fs.createWriteStream("bundle.js"))
@@ -146,10 +146,10 @@ These are the built-in preprocessors:
146146

147147
- stylus
148148
- less
149-
- scss (via `node-sass`)
149+
- scss (via `node-sass`, use `sass` in [config section](#configuring-options))
150150
- jade
151151
- pug
152-
- coffee-script
152+
- coffee-script (use `coffee` in [config section](#configuring-options))
153153

154154
## Autoprefix by Default
155155

@@ -220,12 +220,30 @@ vueify.compiler.applyConfig({
220220
// ...same as in vue.config.js
221221
})
222222

223-
browserify('./entry.js')
223+
browserify('./main.js')
224224
.transform(vueify)
225225
.bundle()
226226
.pipe(fs.createWriteStream("bundle.js"))
227227
```
228228

229+
Or simply pass configuration object to `vueify` (in Node) (for instance to set sass search paths as in the following example):
230+
231+
``` js
232+
var fs = require("fs")
233+
var browserify = require('browserify')
234+
var vueify = require('vueify')
235+
236+
browserify('./main.js')
237+
.transform(vueify, {
238+
sass: {
239+
includePaths: [...]
240+
},
241+
// ...same as in vue.config.js
242+
})
243+
.bundle()
244+
.pipe(fs.createWriteStream("bundle.js"))
245+
```
246+
229247
### Scoped CSS
230248

231249
> Experimental

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ var compiler = require('./lib/compiler')
33

44
compiler.loadConfig()
55

6-
module.exports = function vueify (file) {
6+
module.exports = function vueify (file, options) {
77
if (!/.vue$/.test(file)) return through()
8+
compiler.applyConfig(options)
9+
810
var data = ''
911
var stream = through(write, end)
1012

1113
function dependency(file) {
1214
stream.emit('file', file)
1315
}
14-
16+
1517
function write(buf) {
1618
data += buf
1719
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy