Is there any way to let laravel-mix transpile third party js files?
See original GitHub issue-
Laravel Mix Version: 0.9.2
-
Node Version (
node -v
): v6.9.4 -
NPM Version (
npm -v
): 3.10.10 -
OS: Cent OS 7.3
Description:
I am new to Laravel and Vue. and currently I use Larave5.4 + Vue 2.0 to develop a website. I imported a third party UI component, which is from vue-strap. Everything goes well on Chrome, Safari and Firefox. However, because IE11 doesn’t support ES6, and the js files in vue-strap lib are written in ES6, there are erros on IE11. I thought Laravel-mix will compile all the file into ES5 format. But when I check the app.js file, those js files in vue-strap lib are not transpiled into ES5. My .babelrc in the root is as below.
{ “presets”: [ [“es2015”, { “modules”: false }], ], “plugins”: [“transform-es2015-destructuring”, “transform-object-rest-spread”] }
My understanding is that laravel-mix will compile all the js and vue files including those imported from the third party lib based on .babelrc into public/js/app.js. Am I right? But in my case, it seems that larabel-mix only compile the js and vue file of own project.
Thus, I have to manually compile third those js file into ES5 format,then run [npm run dev] to complie all js files into app.js. This will solve the problem.
My question is that is there any way to let laravel-mix compile all imported js and vue files from third party lib as well?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Is there any way to let laravel-mix transpile third party js files?
My understanding is that laravel-mix will compile all the js and vue files including those imported from the third party lib based on ......
Read more >JavaScript | Laravel Mix Documentation
To trigger the compilation, run npm run dev from the command line. Vue Components. Laravel Mix is mildly opinionated, and ships with compilation...
Read more >Laravel Mix - CSS and Java Compilation Made Easy
Open command prompt or Terminal, go to your project directory, and install laravel-mix via npm or yarn . We also recommend installing the ......
Read more >How to use third-party JavaScript libraries in Laravel Mix
I usually combine common scripts and styles (jquery, bootstrap, blockui, etc) in a "common. js" (or app. js) and "common. css" with laravel...
Read more >Adding Typescript to your Existing Rails App - Honeybadger.io
This is one of the ways to add types to third-party libraries that lack them, making it possible for the compiler to provide...
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
Add a rule
{ test: /\.js$/, loaders: ['babel-loader'] },
in your webpack.config.js , it works! @larryu@Anluis Thanks mate. This works. Seems a good way to solve this issue.