├── .babelrc ├── .eslintignore ├── .eslintrc ├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── .vscode └── launch.json ├── LICENSE ├── README.md ├── appveyor.yml ├── circle.yml ├── dev ├── .eslintrc ├── dist │ ├── build-react.js │ └── build-vue.js ├── vue.component.js ├── vue.js ├── vue.md ├── vue.options.js └── vue.render.js ├── docs ├── LANGS.md ├── assets │ ├── CNAME │ └── circle.yml ├── book.json ├── deploy.sh ├── en │ ├── README.md │ ├── SUMMARY.md │ ├── configurations │ │ ├── advanced.md │ │ ├── asset-url.md │ │ ├── custom-blocks.md │ │ ├── extract-css.md │ │ └── pre-processors.md │ ├── features │ │ ├── css-modules.md │ │ ├── es2015.md │ │ ├── hot-reload.md │ │ ├── postcss.md │ │ └── scoped-css.md │ ├── options.md │ ├── start │ │ ├── setup.md │ │ └── spec.md │ └── workflow │ │ ├── linting.md │ │ ├── production.md │ │ ├── testing-with-mocks.md │ │ └── testing.md ├── ja │ ├── README.md │ ├── SUMMARY.md │ ├── configurations │ │ ├── advanced.md │ │ ├── asset-url.md │ │ ├── custom-blocks.md │ │ ├── extract-css.md │ │ └── pre-processors.md │ ├── features │ │ ├── css-modules.md │ │ ├── es2015.md │ │ ├── hot-reload.md │ │ ├── postcss.md │ │ └── scoped-css.md │ ├── options.md │ ├── start │ │ ├── setup.md │ │ └── spec.md │ └── workflow │ │ ├── linting.md │ │ ├── production.md │ │ ├── testing-with-mocks.md │ │ └── testing.md ├── kr │ ├── README.md │ ├── SUMMARY.md │ ├── configurations │ │ ├── advanced.md │ │ ├── asset-url.md │ │ ├── custom-blocks.md │ │ ├── extract-css.md │ │ └── pre-processors.md │ ├── features │ │ ├── css-modules.md │ │ ├── es2015.md │ │ ├── hot-reload.md │ │ ├── postcss.md │ │ └── scoped-css.md │ ├── options.md │ ├── start │ │ ├── setup.md │ │ └── spec.md │ └── workflow │ │ ├── linting.md │ │ ├── production.md │ │ ├── testing-with-mocks.md │ │ └── testing.md ├── pt_BR │ ├── README.md │ ├── SUMMARY.md │ ├── configurations │ │ ├── advanced.md │ │ ├── asset-url.md │ │ ├── custom-blocks.md │ │ ├── extract-css.md │ │ └── pre-processors.md │ ├── features │ │ ├── css-modules.md │ │ ├── es2015.md │ │ ├── hot-reload.md │ │ ├── postcss.md │ │ └── scoped-css.md │ ├── options.md │ ├── start │ │ ├── setup.md │ │ └── spec.md │ └── workflow │ │ ├── linting.md │ │ ├── production.md │ │ ├── testing-with-mocks.md │ │ └── testing.md ├── ru │ ├── README.md │ ├── SUMMARY.md │ ├── configurations │ │ ├── advanced.md │ │ ├── asset-url.md │ │ ├── custom-blocks.md │ │ ├── extract-css.md │ │ └── pre-processors.md │ ├── features │ │ ├── css-modules.md │ │ ├── es2015.md │ │ ├── hot-reload.md │ │ ├── postcss.md │ │ └── scoped-css.md │ ├── options.md │ ├── start │ │ ├── setup.md │ │ └── spec.md │ └── workflow │ │ ├── linting.md │ │ ├── production.md │ │ ├── testing-with-mocks.md │ │ └── testing.md └── zh-cn │ ├── README.md │ ├── SUMMARY.md │ ├── configurations │ ├── advanced.md │ ├── asset-url.md │ ├── custom-blocks.md │ ├── extract-css.md │ └── pre-processors.md │ ├── features │ ├── css-modules.md │ ├── es2015.md │ ├── hot-reload.md │ ├── postcss.md │ └── scoped-css.md │ ├── options.md │ ├── start │ ├── setup.md │ └── spec.md │ └── workflow │ ├── linting.md │ ├── production.md │ ├── testing-with-mocks.md │ └── testing.md ├── index.js ├── lib ├── getRequireModule │ └── index.js ├── loader.js ├── parser.js ├── script-compiler │ ├── index.js │ └── modules │ │ └── parser.js ├── selector.js ├── style-compiler │ ├── index.js │ ├── load-postcss-config.js │ └── plugins │ │ ├── scope-id.js │ │ └── trim.js ├── template-compiler │ ├── index.js │ ├── modules │ │ └── transform-require.js │ ├── plugins │ │ └── addvm.js │ └── preprocessor.js └── utils │ ├── gen-id.js │ ├── normalize.js │ ├── output-file.js │ └── try-require.js ├── package.json ├── server.js ├── test ├── fixtures │ ├── basic.vue │ ├── css-modules.vue │ ├── custom-blocks.vue │ ├── custom-import.vue │ ├── custom-language.vue │ ├── custom-module.js │ ├── custom-module.vue │ ├── custom-options.vue │ ├── es2015.vue │ ├── extend.vue │ ├── extract-css.vue │ ├── functional-style.vue │ ├── inject.js │ ├── inject.vue │ ├── logo.png │ ├── markdown.vue │ ├── media-query.vue │ ├── postcss.vue │ ├── pre.vue │ ├── resolve.vue │ ├── scoped-css.vue │ ├── script-import.js │ ├── script-import.vue │ ├── service.js │ ├── ssr-style.js │ ├── ssr-style.vue │ ├── style-import-scoped.css │ ├── style-import.css │ ├── style-import.vue │ ├── template-import.pug │ ├── template-import.vue │ ├── transform.vue │ └── unit-test.js ├── mock-loaders │ ├── blog.js │ ├── css.js │ ├── docs.js │ ├── html.js │ ├── i18n.js │ ├── js.js │ └── yaml.js └── test.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015"] 3 | } 4 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmallComfort/react-vue-loader/c9af7291cac69083b4711156780f3135d0ff1063/.eslintignore -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": "vue" 4 | } 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | test/output 4 | docs/_book 5 | .DS_Store 6 | .idea 7 | *.iml 8 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible Node.js debug attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "启动程序", 11 | "program": "${workspaceRoot}/server.js" 12 | }, 13 | { 14 | "type": "node", 15 | "request": "attach", 16 | "name": "附加到端口", 17 | "address": "localhost", 18 | "port": 5858 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-present Yuxi (Evan) You 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-vue-loader 2 | 3 | A fork of vue-loader, use to compile the vue component into a react component. 4 | 5 | ## Install 6 | ``` 7 | npm install --save react-vue react-vue-helper 8 | npm install --save-dev react-vue-loader 9 | ``` 10 | 11 | ## Usage 12 | One possible configuration is as follows: 13 | ```javascript 14 | module: { 15 | rules: [ 16 | { 17 | test: /\.vue$/, 18 | loader: 'react-vue-loader' 19 | } 20 | ] 21 | } 22 | ``` 23 | [demo](https://github.com/SmallComfort/react-vue-demo) 24 | 25 | It supports almost all configurations of [vue-loader](https://vue-loader.vuejs.org). If you have used vue-loader, in most cases you only need to change your loader configuration ```loader: 'vue-loader'``` to ```loader: 'react-vue-loader'```. Refer to the [vue-loader](https://vue-loader.vuejs.org) for detailed configuration. 26 | 27 | ### Some Difference 28 | 29 | * react-vue-loader does not support [custom blocks](https://vue-loader.vuejs.org/en/configurations/custom-blocks.html) 30 | 31 | * Use [react-hot-loader](https://github.com/gaearon/react-hot-loader) to achieve hot reload 32 | 33 | * react-vue-loader adds additional options: ```vue```, ```output``` 34 | 35 | 36 | ### Additional Options 37 | 38 | #### ```vue``` 39 | * type: ```String``` 40 | 41 | Used to import a global vue configuration. The loader will load the configuration and apply it to each vue component. 42 | 43 | ```javascript 44 | // vue.config.js 45 | import Vue from 'react-vue'; 46 | import Vuex from 'vuex'; 47 | import VueMaterial from 'vue-material/src' 48 | 49 | Vue.use(Vuex); 50 | Vue.use(VueMaterial); 51 | 52 | export default Vue; 53 | ``` 54 | 55 | ```javascript 56 | module: { 57 | rules: [ 58 | { 59 | test: /\.vue$/, 60 | loader: 'react-vue-loader', 61 | options: { 62 | vue: './vue.config.js' 63 | } 64 | } 65 | ] 66 | } 67 | ``` 68 | 69 | #### ```output``` 70 | * type: ```[Boolean, String]``` 71 | * default: ```false``` 72 | 73 | > Be cautious, it just creates a file and can not remove the file later, when you may want to delete one by one. 74 | 75 | Set ```true``` to see how the vue code is compiled into the react code, which will generate four js files in the same directory. To customize the generated file name, set a string type for ```output``` 76 | 77 | ```javascript 78 | module: { 79 | rules: [ 80 | { 81 | test: /\.vue$/, 82 | loader: 'react-vue-loader', 83 | options: { 84 | output: true 85 | // output: 'custome-name' 86 | } 87 | } 88 | ] 89 | } 90 | ``` 91 | 92 | 93 | ## License 94 | 95 | [MIT](http://opensource.org/licenses/MIT) 96 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # Test against the latest version of this Node.js version 2 | environment: 3 | nodejs_version: "6" 4 | 5 | # Install scripts. (runs after repo cloning) 6 | install: 7 | # Get the latest stable version of Node.js or io.js 8 | - ps: Install-Product node $env:nodejs_version 9 | # install modules 10 | - npm install 11 | 12 | # Post-install test scripts. 13 | test_script: 14 | # Output useful info for debugging. 15 | - node --version 16 | - npm --version 17 | # run tests 18 | - npm test 19 | 20 | # Don't actually build. 21 | build: off 22 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | node: 3 | version: 6 4 | -------------------------------------------------------------------------------- /dev/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "space-before-function-paren": 0, 4 | "quotes": 0, 5 | "semi": 0, 6 | "comma-dangle": 0, 7 | "operator-linebreak": 0, 8 | "eol-last": 0, 9 | "camelcase": 0 10 | } 11 | } -------------------------------------------------------------------------------- /dev/vue.component.js: -------------------------------------------------------------------------------- 1 | import Vue, { 2 | observer 3 | } from 'react-vue' 4 | 5 | import { 6 | Component 7 | } from 'react' 8 | 9 | import PropTypes from 'prop-types' 10 | 11 | import { 12 | buildComponent, 13 | platformDirectives 14 | } from 'react-vue-helper' 15 | import VueConfiger from "../index.js" 16 | export default (render, options, cssModules) => { 17 | return observer( 18 | class Vue extends buildComponent( 19 | render, Object.assign({}, { 20 | directives: platformDirectives 21 | }, options), { 22 | Component, 23 | PropTypes, 24 | Vue, 25 | cssModules, 26 | VueConfiger 27 | } 28 | ) {} 29 | ) 30 | } -------------------------------------------------------------------------------- /dev/vue.js: -------------------------------------------------------------------------------- 1 | require("!!style-loader!css-loader!../lib/style-compiler/index?{\"vue\":true,\"id\":\"data-v-78b356af\",\"scoped\":false,\"hasInlineConfig\":false}!../lib/selector?type=styles&index=0!./vue.md"); 2 | 3 | var render = require("!!babel-loader!../lib/utils/output-file?{\"output\":\"\",\"type\":\"render\"}!../lib/template-compiler/index?{\"id\":\"data-v-78b356af\",\"scoped\":false}!../lib/selector?type=template&index=0!./vue.md").default; 4 | 5 | var options = require("!!babel-loader!../lib/utils/output-file?{\"output\":\"\",\"type\":\"options\"}!../lib/selector?type=script&index=0!./vue.md"); 6 | options = options.default || options; 7 | 8 | var build = require("!!babel-loader!../lib/utils/output-file?{\"output\":\"\",\"type\":\"component\"}!../lib/script-compiler/index?{\"name\":\"vue\",\"vue\":\"./index.js\"}!../lib/selector?type=script&index=0!./vue.md").default; 9 | 10 | var Component = build(render, Object.assign({}, options, { 11 | __file: "/Users/smallcomfort/Desktop/study/vue-loader/dev/vue.md" 12 | })); 13 | 14 | module.exports = Component; -------------------------------------------------------------------------------- /dev/vue.options.js: -------------------------------------------------------------------------------- 1 | var iconList = require('examples/icon.json'); 2 | 3 | export default { 4 | data() { 5 | return { 6 | icons: iconList 7 | }; 8 | } 9 | } -------------------------------------------------------------------------------- /docs/LANGS.md: -------------------------------------------------------------------------------- 1 | * [English](en/) 2 | * [한국어](kr/) 3 | * [Русский](ru/) 4 | * [Português](pt_BR/) 5 | * [日本語](ja/) 6 | * [中文](zh-cn/) 7 | -------------------------------------------------------------------------------- /docs/assets/CNAME: -------------------------------------------------------------------------------- 1 | vue-loader.vuejs.org 2 | -------------------------------------------------------------------------------- /docs/assets/circle.yml: -------------------------------------------------------------------------------- 1 | general: 2 | branches: 3 | ignore: 4 | - gh-pages 5 | -------------------------------------------------------------------------------- /docs/book.json: -------------------------------------------------------------------------------- 1 | { 2 | "gitbook": ">3.0.0", 3 | "plugins": ["edit-link", "theme-vuejs@git+https://github.com/pearofducks/gitbook-plugin-theme-vuejs.git", "-fontsettings", "github"], 4 | "pluginsConfig": { 5 | "edit-link": { 6 | "base": "https://github.com/vuejs/vue-loader/tree/master/docs", 7 | "label": "Edit This Page" 8 | }, 9 | "github": { 10 | "url": "https://github.com/vuejs/vue-loader/" 11 | } 12 | }, 13 | "links": { 14 | "sharing": { 15 | "facebook": false, 16 | "twitter": false 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /docs/deploy.sh: -------------------------------------------------------------------------------- 1 | cd docs 2 | rm -rf _book 3 | gitbook build 4 | cp assets/circle.yml _book/circle.yml 5 | cp assets/CNAME _book/CNAME 6 | cd _book 7 | git init 8 | git add -A 9 | git commit -m 'update book' 10 | git push -f git@github.com:vuejs/vue-loader.git master:gh-pages 11 | -------------------------------------------------------------------------------- /docs/en/README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | ### What is `vue-loader`? 4 | 5 | `vue-loader` is a loader for Webpack that can transform Vue components written in the following format into a plain JavaScript module: 6 | 7 | ![screenshot](http://blog.evanyou.me/images/vue-component.png) 8 | 9 | There are many cool features provided by `vue-loader`: 10 | 11 | - ES2015 enabled by default; 12 | - Allows using other Webpack loaders for each part of a Vue component, for example SASS for ` 17 | ``` 18 | 19 | Under the hood, the text content inside the ` 79 | ``` 80 | 81 | However, note this makes your Vue component Webpack-specific and not compatible with Browserify and [vueify](https://github.com/vuejs/vueify). **If you intend to ship your Vue component as a reusable 3rd-party component, avoid using this syntax.** 82 | -------------------------------------------------------------------------------- /docs/en/features/es2015.md: -------------------------------------------------------------------------------- 1 | # ES2015 2 | 3 | When `vue-loader` detects the presence of `babel-loader` or `buble-loader` in the same project, it will use them to process the ` 23 | ``` 24 | 25 | We are using ES2015's Object literal shorthand here to define the child components. `{ ComponentA }` is simply shorthand for `{ ComponentA: ComponentA }`. Vue will automatically convert the key to `component-a`, so you can use the imported component in the template as ``. 26 | 27 | ### ES2015 in Templates 28 | 29 | `