LoginSignup
0
1

More than 5 years have passed since last update.

Laravelでbootstrap4をwebpackでまとめる

Posted at

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

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1