您好我正在使用laravel mix和我的Laravel 5.5
我的混音文件是这样的:
/* Production settings */
if (mix.inProduction()) {
mix.version();
mix.disableNotifications();
}
/* Sass Processing */
mix.sass('resources/assets/sass/_bootstrap.scss', 'public/css/bootstrap.css');
mix.sass('resources/assets/sass/navigation.scss', 'public/css/navigation.css');
mix.sass('resources/assets/sass/global.scss', 'public/css/global.css').options({
processCssUrls: false
});
mix.sass('resources/assets/sass/cards.scss', 'public/css/cards.css')
.sass('resources/assets/sass/forms.scss', 'public/css/forms.css')
.sass('resources/assets/sass/search.scss', 'public/css/search.css')
.sass('resources/assets/sass/profile.scss', 'public/css/profile.css')
.sass('resources/assets/sass/event.scss', 'public/css/event.css')
.sass('resources/assets/sass/entity.scss', 'public/css/entity.css')
.sass('resources/assets/sass/travel.scss', 'public/css/travel.css')
.sass('resources/assets/sass/sliders.scss', 'public/css/sliders.css')
.sass('resources/assets/sass/login.scss', 'public/css/login.css');
mix.styles([
'resources/assets/css/bootstrap-social.css',
'resources/assets/css/dropzone.css',
'resources/assets/css/jquery-ui.css',
'resources/assets/css/jquery-ui.structure.css',
'resources/assets/css/jquery-ui.theme.css',
'resources/assets/css/font-awesome.css',
'resources/assets/css/animate.css',
], 'public/css/style.css');
/* Global JS */
mix.scripts([
'resources/assets/js/pace.js',
'resources/assets/js/jquery.js',
'resources/assets/js/page-load.js',
'resources/assets/js/bootstrap.js',
'resources/assets/js/jquery-ui.js',
'resources/assets/js/favourites.js',
], 'public/js/global.js');
mix.js('resources/assets/js/dropzone.js', 'public/js/dropzone.js');
mix.js('resources/assets/js/image-upload.js', 'public/js/image-upload.js');
mix.js('resources/assets/js/googlemap.js', 'public/js/googlemap.js');
mix.js('resources/assets/js/entity.js', 'public/js/entity.js');
mix.js('resources/assets/js/validation.js', 'public/js/validation.js');
mix.js('resources/assets/js/search.js');
mix.js('resources/assets/js/homesearch.js', 'public/js/homesearch.js');
mix.js('resources/assets/js/instantsearch.js', 'public/js/instantsearch.js');
mix.js('resources/assets/js/featured.js', 'public/js/featured.js');
mix.js('resources/assets/js/tram.js', 'public/js/tram.js');
mix.js('resources/assets/js/counter.js', 'public/js/counter.js');
我想要做的是使用文档中提到的提取方法:
供应商提取将所有特定于应用程序的JavaScript与供应商库捆绑在一起的一个潜在缺点就是它 使长期缓存更加困难。例如,单个更新 您的应用程序代码将强制浏览器重新下载所有 您的供应商库即使它们没有改变。
如果您打算经常更新您的应用程序 JavaScript,您应该考虑提取所有供应商 库到自己的文件中。这样,就可以更改您的应用程序 代码不会影响大型vendor.js文件的缓存。混合' S 提取方法使这变得轻而易举:
mix.js('resources/assets/js/app.js', 'public/js') .extract(['vue'])
extract方法接受所有库或模块的数组 您希望提取到vendor.js文件中。使用上面的代码段作为 例如,Mix将生成以下文件:
public / js / manifest.js:Webpack清单运行时 public / js / vendor.js:您的供应商库public / js / app.js:您的 应用程序代码为避免JavaScript错误,请务必加载这些错误 文件按正确顺序排列:
<script src="/js/manifest.js"></script>
<scrip src="/js/vendor.js"></script>
<script src="/js/app.js"></script>
所以我在:resources / aseets / js / app.js和我的webpack中创建了一个空文件:
mix.js('resources/assets/js/app.js', 'public/js')
.extract(['jquery', 'bootstrap', 'pace'])
一切都在成功处理,我附上了所有文件。 app.js似乎需要内容,但是当我到达页面时,显然jquery没有被定义。
可能是什么原因?我已经安装了bootstrap,jquery和npm
答案 0 :(得分:0)
使用vue,jquery插件有一定的冲突
https://vuejsdevelopers.com/2017/05/20/vue-js-safely-jquery-plugin/