在laravel 5.5中包含node_modules的简单方法

时间:2017-11-25 02:02:12

标签: laravel

如何在laravel 5.5应用程序中包含/ node_modules,我引用了这个https://laravel.com/docs/5.5/mix

我能做到这一点

npm install angular-moment moment --save

它将创建一个/ node_modules目录,但是laravel会忽略它

我想说我想这样做

<script src="node_modules/moment/moment.js"></script>

它不起作用,它会显示错误

我目前在我的webpack中有这个,这将是集成它的最佳方式吗?

let mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');

1 个答案:

答案 0 :(得分:10)

只需将其包含在您的app.js中,即可遵守...

var moment = require('moment');

然后访问它......就像

一样
moment().format();