5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

LaravelのWebpackの速度改善

Last updated at Posted at 2020-04-24

#watchがおそすぎる

  • CPU負荷が常に大きい場合は監視対象が多すぎる可能性が高い
  • /node_modules/をwatchの監視対象から外す
webpack.mix.js
const mix = require('laravel-mix')
mix.webpackConfig({
  watchOptions: {
    ignored: /node_modules/
  }
})

参考:
WebpackでHot Module Replacementを使用する時のCPU使用率を改善する
How to ignore node_modules when running the watcher in Laravel Mix & Nuxt.js

コンパイルが遅い

  • HardSourcePluginをインストールする
# インストール
npm install --save hard-source-webpack-plugin

# アンインストールの場合
npm uninstall hard-source-webpack-plugin --save
webpack.mix.js
var HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
mix.webpackConfig({
    plugins: [
        new HardSourceWebpackPlugin()
    ]
})

参考:
Webpackのコンパイル速度改善HardSourcePlugin

5
3
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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?