Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationEventAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.


webpack v3でriotJSのビルド設定

webpack v1 => v2 => v3の流れでwebpack.config.jsの仕様がころころ変わってる模様。ここが変わるのは苦しいがさすがにそろそろ安定してくるはず。

DEV_PACKAGES="webpack@3.0.0 path riotjs-loader babel babel-core babel-loader babel-preset-es2015 babel-preset-es2015-riot"
yarn add --dev ${DEV_PACKAGES}
  # npm install --save-dev ${DEV_PACKAGES}

yarn add riot
  # npm install --save riot


var webpack = require('webpack')
const path = require('path')

module.exports = {
  entry: './node_assets/javascripts/main.js',
  output: {
    path: path.resolve(__dirname, 'app/assets/javascripts'),
    filename: 'app.bundle.js'
  module: {
    rules: [
        test: /\.tag$/,
        exclude: /node_modules/,
        loader: "riotjs-loader",
        enforce: "pre",
        test: /\.js[x]?$|\.tag$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        options: {
          presets: ['es2015-riot']
  plugins: [
    new webpack.ProvidePlugin({
      riot: 'riot'

  • プラットフォーム差の問題でoutputパスを絶対パスで指定するようになったぽい
  • preLoaders,loaders設定は廃止されていて、rules設定に統一されている
  • riotTagをjavascript変換して、さらにそれをes2015に変換するためには、riotjs-loaderpreで動かす(enforce:"pre"を指定)
  • es2015にしないと、webpack --optimize-minimizeがエラーになった
  # 以下の警告は出るが、コンパイルはできた
  # loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
  # parseQuery() will be replaced with getOptions() in the next major version of loader-utils.

webpack --optimize-minimize
  # ls -l /path/to/compiled.js
  # 圧縮を確認


Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Help us understand the problem. What are the problem?