Help us understand the problem. What is going on with this article?

webpack v3でriotJSのビルド設定

More than 3 years have passed since last update.

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

webpack.config.js

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がエラーになった
webpack
  # 以下の警告は出るが、コンパイルはできた
  # 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
  # 圧縮を確認

References

https://webpack.js.org/configuration/

metheglin
敷布団カバーと掛布団カバーを逆につけて寝ています
https://metheglin.jp/#logical
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした