├── .editorconfig ├── .gitignore ├── .jshintrc ├── LICENSE ├── README.md ├── index.js └── package.json /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | insert_final_newline = true 3 | indent_style = space 4 | indent_size = 2 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | node_modules 3 | npm-debug.log 4 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "undef": true, 3 | "unused": true, 4 | "indent": 2, 5 | "noempty": true, 6 | "node": true, 7 | "globals": { 8 | "describe": false, 9 | "before": false, 10 | "beforeEach": false, 11 | "afterEach": false, 12 | "it": false, 13 | "xit": false, 14 | "emit": false 15 | }, 16 | "multistr": true 17 | } 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Eduardo Nunes 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # riotjs module loader for webpack 2 | 3 | ## install 4 | ```bash 5 | npm install --save-dev riot riotjs-loader babel babel-loader webpack webpack-dev-server 6 | ``` 7 | 8 | ## usage 9 | 10 | ### /webpack.config.js 11 | ```javascript 12 | var webpack = require('webpack'); 13 | 14 | module.exports = { 15 | entry: './app/index', 16 | output: { 17 | path: __dirname + '/public', 18 | filename: 'bundle.js' 19 | }, 20 | plugins: [ 21 | new webpack.ProvidePlugin({ 22 | riot: 'riot' 23 | }) 24 | ], 25 | module: { 26 | preLoaders: [ 27 | { test: /\.tag$/, exclude: /node_modules/, loader: 'riotjs-loader', query: { type: 'none' } } 28 | ], 29 | loaders: [ 30 | { test: /\.js$|\.tag$/, exclude: /node_modules/, loader: 'babel-loader' } 31 | ] 32 | }, 33 | devServer: { 34 | contentBase: './public' 35 | } 36 | }; 37 | ``` 38 | 39 | ### /public/index.html 40 | ```html 41 | 42 | 43 | 44 | 45 | App 46 | 47 | 48 | 49 | 50 | 51 | 52 | ``` 53 | 54 | ### /app/index.js 55 | ```javascript 56 | require('./app.tag'); 57 | 58 | riot.mount('*'); 59 | ``` 60 | 61 | ### /app/app.tag 62 | ```html 63 | require('./name.tag'); 64 | 65 | 66 | 67 | 68 | 69 | ``` 70 | 71 | ### /app/name.tag 72 | ```html 73 | 74 |

{ opts.last }, { opts.first }

75 |
76 | ``` 77 | 78 | ## development 79 | 80 | ```bash 81 | ./node_modules/.bin/webpack-dev-server --inline --hot 82 | ``` 83 | - open http://localhost:8080/ 84 | 85 | ## LICENSE 86 | 87 | (MIT License) 88 | 89 | Copyright (c) 2015 Eduardo Nunes 90 | 91 | Permission is hereby granted, free of charge, to any person obtaining a copy 92 | of this software and associated documentation files (the "Software"), to deal 93 | in the Software without restriction, including without limitation the rights 94 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 95 | copies of the Software, and to permit persons to whom the Software is 96 | furnished to do so, subject to the following conditions: 97 | 98 | The above copyright notice and this permission notice shall be included in 99 | all copies or substantial portions of the Software. 100 | 101 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 102 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 103 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 104 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 105 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 106 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 107 | THE SOFTWARE. 108 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var riot = require('riot-compiler'), 2 | loaderUtils = require('loader-utils'); 3 | 4 | 5 | module.exports = function (source) { 6 | 7 | var content = source; 8 | var options = loaderUtils.parseQuery(this.query); 9 | 10 | if (this.cacheable) this.cacheable(); 11 | 12 | Object.keys(options).forEach(function(key) { 13 | switch(options[key]) { 14 | case 'true': 15 | options[key] = true; 16 | break; 17 | case 'false': 18 | options[key] = false; 19 | break; 20 | case 'undefined': 21 | options[key] = undefined; 22 | break; 23 | case 'null': 24 | options[key] = null; 25 | break; 26 | } 27 | }); 28 | 29 | try { 30 | return riot.compile(content, options); 31 | } catch (e) { 32 | if (e instanceof Error) { 33 | throw e; 34 | } else { 35 | throw new Error(e); 36 | } 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "riotjs-loader", 3 | "version": "4.0.0", 4 | "description": "riotjs module loader for webpack", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/esnunes/riotjs-loader.git" 12 | }, 13 | "keywords": [ 14 | "webpack", 15 | "loader", 16 | "riot", 17 | "riotjs", 18 | "module" 19 | ], 20 | "author": { 21 | "name": "Eduardo Nunes", 22 | "email": "esnunes@gmail.com" 23 | }, 24 | "license": "MIT", 25 | "bugs": { 26 | "url": "https://github.com/esnunes/riotjs-loader/issues" 27 | }, 28 | "homepage": "https://github.com/esnunes/riotjs-loader", 29 | "dependencies": { 30 | "loader-utils": "^0.2.6", 31 | "riot-compiler": "^3.0.0" 32 | }, 33 | "peerDependencies": { 34 | "webpack": "^1.5.3" 35 | } 36 | } 37 | --------------------------------------------------------------------------------