You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 26, 2018. It is now read-only.
If you are using npm 3+, it no longer auto install the peer dependencies. So you will also have to also install the babel-related dependencies:
71
-
72
-
```bash
73
-
npm install\
74
-
babel-core\
75
-
babel-preset-es2015\
76
-
babel-runtime\
77
-
babel-plugin-transform-runtime\
78
-
--save-dev
79
-
```
80
-
81
70
And this is all you need to do in your main entry file:
82
71
83
72
```js
@@ -86,9 +75,9 @@ var Vue = require('vue')
86
75
var App =require('./app.vue')
87
76
88
77
newVue({
89
-
el:'body',
90
-
components: {
91
-
app:App
78
+
el:'#app',
79
+
render:function (createElement) {
80
+
returncreateElement(App)
92
81
}
93
82
})
94
83
```
@@ -97,7 +86,7 @@ In your HTML:
97
86
98
87
```html
99
88
<body>
100
-
<app></app>
89
+
<divid="app"></div>
101
90
<scriptsrc="build.js"></script>
102
91
</body>
103
92
```
@@ -121,35 +110,34 @@ Make sure to have the `NODE_ENV` environment variable set to `"production"` when
121
110
122
111
If you are using Gulp, note that `gulp --production`**does not** affect vueify; you still need to explicitly set `NODE_ENV=production`.
123
112
124
-
## ES2015 by Default
125
-
126
-
Vueify automatically transforms the JavaScript in your `*.vue` components using Babel. Write ES2015 today!
113
+
## ES2015 with Babel
127
114
128
-
The default Babel (6) options used for Vue.js components are:
115
+
Vueify is pre-configured to work with Babel. Simply install Babel-related dependencies:
129
116
130
-
```js
131
-
{
132
-
"presets": ["es2015"],
133
-
"plugins": ["transform-runtime"]
134
-
}
117
+
```bash
118
+
npm install\
119
+
babel-core\
120
+
babel-preset-es2015\
121
+
--save-dev
135
122
```
136
123
137
-
If you wish to override this, you can add a `.babelrc` file at the root of your project:
124
+
Then create a `.babelrc`:
138
125
139
126
```json
140
127
{
141
-
"presets": ["es2015", "stage-2"],
142
-
"plugins": ["transform-runtime"]
128
+
"presets": ["es2015"]
143
129
}
144
130
```
145
131
132
+
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](https://github.com/babel/babelify).
133
+
146
134
You can also configure babel with the `babel` field in `vue.config.js`, which will take the highest priority.
147
135
148
-
## Enabling Pre-Processors
136
+
## Enabling Other Pre-Processors
149
137
150
-
You 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`.
138
+
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`.
151
139
152
-
These are the built-in preprocessors:
140
+
These are the preprocessors supported by vueify out of the box:
153
141
154
142
- stylus
155
143
- less
@@ -158,13 +146,9 @@ These are the built-in preprocessors:
158
146
- pug
159
147
- coffee-script (use `coffee` in [config section](#configuring-options))
160
148
161
-
## Autoprefix by Default
162
-
163
-
Starting in 5.0.0, all CSS output via vueify will be autoprefixed by default. See [config section](#configuring-options) below on customizing the options.
164
-
165
149
## PostCSS
166
150
167
-
Vueify uses PostCSS for scoped CSS rewrite and autoprefixing. You can also provide your own PostCSS plugins! See [config section](#configuring-options) below for an example.
151
+
Vueify uses PostCSS for scoped CSS rewrite. You can also provide your own PostCSS plugins! See [config section](#configuring-options) below for an example.
168
152
169
153
## Configuring Options
170
154
@@ -178,15 +162,6 @@ module.exports = {
178
162
},
179
163
// provide your own postcss plugins
180
164
postcss: [...],
181
-
// configure autoprefixer
182
-
autoprefixer: {
183
-
browsers: ['last 2 versions']
184
-
},
185
-
// configure html minification in production mode
186
-
// see https://github.com/kangax/html-minifier#options-quick-reference
187
-
htmlMinifier: {
188
-
// ...
189
-
},
190
165
// register custom compilers
191
166
customCompilers: {
192
167
// for tags with lang="ts"
@@ -209,9 +184,7 @@ Example using custom PostCSS plugin:
209
184
var cssnext =require('cssnext')
210
185
211
186
module.exports= {
212
-
postcss: [cssnext()],
213
-
// disable autoprefixer since cssnext comes with it
214
-
autoprefixer:false
187
+
postcss: [cssnext()]
215
188
}
216
189
```
217
190
@@ -253,8 +226,6 @@ browserify('./main.js')
253
226
254
227
### Scoped CSS
255
228
256
-
> Experimental
257
-
258
229
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:
259
230
260
231
```html
@@ -285,22 +256,20 @@ Into the following:
285
256
286
257
1. You can include both scoped and non-scoped styles in the same component.
287
258
288
-
2.A child component's root node will be affected by both the parent's scoped CSS and the child's scoped CSS.
289
-
290
-
3. Partials are not affected by scoped styles.
259
+
2.The following will be affected by both the parent's scoped CSS and the child's scoped CSS:
260
+
- A child component's root node
261
+
- Content inserted to a child component via `<slot>`
291
262
292
263
### Hot Reload
293
264
294
-
> Experimental
295
-
296
265
To enable hot component reloading, you need to install the [browserify-hmr](https://github.com/AgentME/browserify-hmr) plugin:
297
266
298
267
```bash
299
268
npm install browserify-hmr --save-dev
300
269
watchify -p browserify-hmr index.js -o bundle.js
301
270
```
302
271
303
-
A full setup example with hot reloading is available at [vuejs/vueify-example](https://github.com/vuejs/vueify-example).
272
+
You can scaffold a hot-reload enabled project easily using `vue-cli` and the [this template](https://github.com/vuejs-templates/browserify-simple-2.0).
304
273
305
274
## Compiler API
306
275
@@ -319,15 +288,9 @@ compiler.compile(fileContent, filePath, function (err, result) {
319
288
320
289
Currently there are syntax highlighting support for [Sublime Text](https://github.com/vuejs/vue-syntax-highlight), [Atom](https://atom.io/packages/language-vue), [Vim](https://github.com/posva/vim-vue), [Visual Studio Code](https://marketplace.visualstudio.com/items/liuji-jim.vue) and [Brackets](https://github.com/pandao/brackets-vue). 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.
321
290
322
-
## Example
323
-
324
-
For an example setup using most of the features mentioned above, see [vuejs/vueify-example](https://github.com/vuejs/vueify-example).
325
-
326
-
If you use Webpack, there's also [vue-loader](https://github.com/vuejs/vue-loader) that does the same thing.
327
-
328
291
## Changelog
329
292
330
-
For version 9.0.0 and above, please see the [Releases](https://github.com/vuejs/vueify/releases) page for changes in each version.
293
+
Please see the [Releases](https://github.com/vuejs/vueify/releases) page for changes in versions ^9.0.0.
0 commit comments