Laravel¿ª·¢£ºÔõÑùʹÓÃLaravel Mix±àÒëÇ°¶Ë×ʲú£¿
laravelÊÇÒ»¿îºÜÊÇÊ¢ÐеÄphp¿ò¼Ü£¬ÆäÇ¿Ê¢µÄ¹¦Ð§ºÍÎÞаµÄ¼Ü¹¹ÎüÒýÁËÐí¶à¿ª·¢ÕߵĹØ×¢¡£ÆäÖУ¬laravel mixÊÇlaravelµÄÒ»¸öÇ¿Ê¢µÄÇ°¶Ë¹¤¾ß£¬ËüÄܹ»×ÊÖúÎÒÃǸü±ã½ÝµØ´¦ÀíÇ°¶Ë×ÊÔ´¡£ÄÇô£¬ÔõÑùʹÓÃlaravel mix±àÒëÇ°¶Ë×ʲúÄØ£¿½ÓÏÂÀ´£¬ÎÒÃǽ«ÏêϸÏÈÈÝlaravel mixµÄʹÓÃÒªÁì¡£
ÔÚLaravelÖÐ×°ÖÃLaravel Mix
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚLaravelÖÐ×°ÖÃLaravel Mix¡£ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´×°Öãº
npm install --save-dev laravel-mix
µÇ¼ºó¸´ÖÆ
´ËÏÂÁÔÚÏîÄ¿ÖÐ×°ÖÃLaravel Mix¡£
±àдWebpack.mix.jsÎļþ
×°ÖÃÍê³ÉLaravel MixÖ®ºó£¬ÎÒÃÇÐèÒª±àдWebpack.mix.jsÎļþ¡£¸ÃÎļþ°üÀ¨ÁËÎÒÃÇÒªÔËÐеÄʹÃüºÍÉèÖã¬ÀýÈçÎÒÃÇÒª±àÒëµÄJSºÍCSSÎļþ¡¢ËùʹÓõIJå¼þ¡¢Êä³öĿ¼µÈ¡£
ÎÒÃÇн¨Ò»¸öWebpack.mix.jsÎļþ²¢Ð´ÈëÒÔÏÂÄÚÈÝ£º
Á¬Ã¦Ñ§Ï°¡°Ç°¶ËÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
let mix = require('laravel-mix'); mix.js('resources/js/app.js', 'public/js') .sass('resources/sass/app.scss', 'public/css');
µÇ¼ºó¸´ÖÆ
ÕâÀÎÒÃÇʹÓÃÁËJavaScriptºÍSASSÕâÁ½ÖÖÇ°¶Ë±à³ÌÓïÑÔ¡£ÎÒÃÇ¿ÉÒÔƾ֤ÏÖʵÐèÒª¾ÙÐÐÐ޸ġ£
ÔËÐбàÒëÏÂÁî
дºÃWebpack.mix.jsÎļþÖ®ºó£¬ÎÒÃǾͿÉÒÔÔËÐбàÒëÏÂÁîÁË¡£ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´ÔËÐбàÒ룺
npm run dev
µÇ¼ºó¸´ÖÆ
¸ÃÏÂÁ×Ô¶¯±àÒëÎÒÃÇÉèÖõÄ×ÊÔ´£¬°üÀ¨JavaScriptºÍSASSÎļþ¡£
ÌØÁíÍâ±àÒëÑ¡Ïî
Laravel Mix»¹Ö§³ÖÐí¶àÌØÁíÍâ±àÒëÑ¡Ïî¡£ÀýÈ磬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´×Ô¶¯¼àÌýËùÓÐÎļþµÄת±ä²¢¾ÙÐÐʵʱ±àÒ룺
npm run watch
µÇ¼ºó¸´ÖÆ
±ðµÄ£¬ÎÒÃÇ»¹¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´¾ÙÐдúÂë´ò°ü£º
npm run production
µÇ¼ºó¸´ÖÆ
Õ⽫¶ÔËùÓÐ×ÊÔ´¾ÙÐÐÉú²ú¼¶±ðµÄ±àÒëºÍѹËõ£¬ÒÔÌá¸ßÍøÕ¾µÄÐÔÄܺͼÓÔØËÙÂÊ¡£
×ܽá
ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÏÈÈÝÁËÔõÑùÔÚLaravelÖÐʹÓÃLaravel Mix±àÒëÇ°¶Ë×ʲú¡£Laravel MixÌṩÁ˺ÜÊDZã½ÝµÄ¹¤¾ßÀ´ÖÎÀíÇ°¶Ë×ÊÔ´£¬ïÔÌÁËÎÒÃǵÄÇ°¶ËÊÂÇéÁ¿¡£Ï£Íû±¾ÎÄÄܹ»×ÊÖú¸÷È˸üºÃµØʹÓÃLaravel Mix¡£
ÒÔÉϾÍÊÇLaravel¿ª·¢£ºÔõÑùʹÓÃLaravel Mix±àÒëÇ°¶Ë×ʲú£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡