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

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

More than 3 years have passed since last update.

@sawadashota

Laravelでbootstrap4をwebpackでまとめる

bootstarp4ではTetherを使っており、以下のようなエラーが出る。

Uncaught Error: Bootstrap tooltips require Tether

Tetherをnpmでインストール

$ npm install tether -S

webpack.mix.jsを修正

以下を追加する。

webpack.mix.js
/**
 * Add tether for bootstrap4
 */
mix.autoload({
    tether: ['Tether', 'window.Tether']
});

結果、webpack.mix.jsはこんな感じに

webpack.mix.js
const { mix } = require('laravel-mix');

/**
 * Add tether for bootstrap4
 */
mix.autoload({
    tether: ['Tether', 'window.Tether']
});

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.react('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css')
   .version();

GitHubのissueではjqueryも読み込ませてますが、とりあえずこれがなくてもコンソールエラーは起きませんでした。もしかしたら必要なのかもしれません・・・
https://github.com/JeffreyWay/laravel-mix/issues/584#issuecomment-287445207

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
2
Help us understand the problem. What are the problem?