Laravel mix does not compile import or require statements
See original GitHub issue- Laravel Mix Version: 1.4.2
- Node Version: 6.11.2
- NPM Version: 3.10.10
- OS: Windows 10
Issue
Laravel Mix does not compile import
or require
. Instead, it simply copies them.
It does not perform minification in production mode either, but that’s a side-issue.
Steps to reproduce
- Create a new npm project.
- Install laravel-mix through npm and copy the scripts to your package.json.
npm install
some package.- Create
app.js
:
import package from 'package'; // Or package = require('package');
- Add
mix.babel('inputpath/app.js', 'outputpath/app.js');
to yourwebpack.mix.js
. - Run
npm run dev
or any other compilation script.
The output file will just be the same as the input file. Meanwhile, other ES6 features are compiled correctly (tested with classes and arrow syntax for example).
Am I missing something, or is this a bug?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
Laravel mix does not compile import or require statements
Laravel Mix does not compile import or require . Instead, it simply copies them. It does not perform minification in production mode either,...
Read more >Laravel mix can not compile import() function - Stack Overflow
You got this import() Unexpected token because missing babel plugin allow parsing of import(). Please try to install one in either:.
Read more >Laravel Mix - Laravel - The PHP Framework For Web Artisans
In other words, Mix makes it a cinch to compile and minify your application's CSS and JavaScript files. Through simple method chaining, you...
Read more >CSS Preprocessors | Laravel Mix Documentation
Should you need to compile more than one root file, you may call mix.sass() (or any of the preprocessor variants) as many as...
Read more >How to compile a set of components into separate files.
Laravel compiles all the components inside App.js, which leaves my file with 400kb. But many components are used in specific areas of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same thing happens to me. I found a workaround here. Don’t know if it affects performance though.
@fiskhandlarn Thanks! That works for now. However, it seems like using
mix.babel
should just work.For me, using
mix.js
without the config you mentioned works in development mode, but crashes in production mode (during minification). With the config, it also works in production.