Andrew Van Slaars 制作了一个很棒的视频,我曾经开始使用 Riot.js + Webpack。
https://www.youtube.com/watch?v=UgdZbT-KPpY
他还提供了一个带有 Riot.js + webpack 的“入门工具包”git repo:https ://github.com/avanslaars/riot-webpack-base
两者都非常有帮助,也是一个很好的起点。
package.json 显示了需要什么——注意使用 tag-loader 而不是 riotjs-loader。我发现标签加载器对我有用,所以没有尝试过 riotjs-loader。
{
"name": "riot-webpack-setup",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack-dev-server"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"riot": "^2.3.11"
},
"devDependencies": {
"babel-core": "^6.3.17",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.3.13",
"tag-loader": "^0.3.0",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0"
}
}
webpack.config 文件很容易开始:
var path = require('path')
module.exports = {
entry: './src/index.js',
output: {
path: __dirname,
filename: 'bundle.js'
},
module:{
loaders:[
{
test: /\.js$/,
loader:'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015']
}
},
{
test: /\.tag$/,
loader: 'tag',
exclude: /node_modules/
}
]
}
}