/laravel-mix-transpile-node-modules

Laravel Mix extension for Babel-transpiling dependencies inside node_modules

Primary LanguageJavaScriptOtherNOASSERTION

Laravel Mix Transpile Node Modules

Software License Latest Version on NPM

Laravel Mix extension for Babel-transpiling dependencies inside node_modules.

Installation

npm install laravel-mix-transpile-node-modules

Usage

Require the extension inside your webpack.mix.js and call transpileNodeModules().

const mix = require('laravel-mix')
require('laravel-mix-transpile-node-modules')

mix.js('src/main.js', 'dist')

/**
 * Transpile node_modules in production
 */
if (mix.inProduction()) {
  mix.transpileNodeModules()
}

Options

Transpile all node modules

This is the default behavior. Same as passing true.

mix.transpileNodeModules()

Transpile selected node modules

Pass an array of npm module names to transpile.

mix.transpileNodeModules(['swiper', 'dom7'])

Don't transpile node modules

Same as not calling the extension at all.

mix.transpileNodeModules(false)