You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Uglify hasn't been working for months. uglifyjs-webpack-pluginhasn't been updated since July 21st and there have been no commits on the repo since then.
Is there a workaround to get uglify working with the latest Laravel Mix version?
Can we maybe just switch to the beta or switch to uglify-es?
@JeffreyWay: It's a Bootstrap v4 modules that's written in ES6. @ankurk91: That's what it looks like.
Setup
git clone https://github.com/tillkruss/laravel-mix-1216
cd laravel-mix-1216
npm install
npm run production
Error
ERROR Failed to compile with 1 errors
dist/test.js from UglifyJs
Unexpected token: punc ()) [./node_modules/bootstrap/js/src/util.js:10,0][dist/test.js:10342,15]
Activity
tillkruss commentedon Sep 22, 2017
As reference, I'm getting the following error:
JeffreyWay commentedon Sep 22, 2017
Uglify is already turned on by default. Are you pulling in a package that was written in ES6? If not, everything should compile properly I think.
Can you give me a simple script example that won't compile down? I'll test it out.
ankurk91 commentedon Sep 22, 2017
If you pull an es6 js file from
node_modules
likemix will not apply babel to it.
Correct me if i am wrong.
tillkruss commentedon Sep 22, 2017
@JeffreyWay: It's a Bootstrap v4 modules that's written in ES6.
@ankurk91: That's what it looks like.
Setup
git clone https://github.com/tillkruss/laravel-mix-1216 cd laravel-mix-1216 npm install npm run production
Error
ankurk91 commentedon Sep 22, 2017
Babel loader is set to exclude
node_modules
https://github.com/JeffreyWay/laravel-mix/blob/master/src/builder/webpack-rules.js#L11
I think this was to speed up build.
P.S.
You can import from
dist
folderhttps://github.com/twbs/bootstrap/blob/v4-dev/dist/js/bootstrap.js#L3899-L3909
tillkruss commentedon Sep 22, 2017
@ankurk91: Importing from
dist
works, but it seems to import the entirebootstrap.js
file, including all modules, not just the ones I imported.ankurk91 commentedon Sep 23, 2017
Did you extract bootstrap with
If so webpack will discard selective import.
If NOT then try
webpack bundle analyser to visualise the modules and their size.
tillkruss commentedon Sep 23, 2017
No, I'm trying to import only specific BSv4 modules.
How would I run the bundle analyser and why?
ankurk91 commentedon Sep 23, 2017
I was suggesting bundle analyzer to get the correct size of each module included.
Here is the link -
https://github.com/th0r/webpack-bundle-analyzer
Here is how to use this in Laravel mix
Then in your webpack.mix.js
Then run
Wait for
http://127.0.0.1:8888/
to be ready for your browser.You can remove this package after using.
tillkruss commentedon Sep 23, 2017
Thanks. When I'm using
import Modal from 'bootstrap/dist/js/bootstrap.js';
the entirebootstrap.js
is imported.From
src
:From
dist
:ankurk91 commentedon Sep 23, 2017
Strange,
Don't know what is missing to fulfill tree shaking requirements
https://webpack.js.org/guides/tree-shaking/
tillkruss commentedon Sep 23, 2017
@JeffreyWay: Any insights?
ankurk91 commentedon Sep 23, 2017
According to bs v4 docs we can can selective import like this
may be you should give it a try.
https://getbootstrap.com/docs/4.0/getting-started/webpack/
ankurk91 commentedon Sep 23, 2017
Yeah just found compiled individual js files,
https://unpkg.com/bootstrap@4.0.0-beta/js/dist/
tillkruss commentedon Sep 23, 2017
@ankurk91: Neat, that worked!