Webpack不在Laravel项目中捆绑JS吗?

时间:2019-04-08 08:46:04

标签: javascript webpack

更新:path: path.resolve(__dirname, '/public/assets/js'),似乎使文件位于根驱动器中?而不是我的laravel文件夹。

从本质上讲,这是有问题的,它没有创建bundle.js文件。

我不想使用Laravel混合,我想首先学习Webpack的方法。 Laravel混合似乎封装了很多东西,这不是我想要的。

webpack.config.js

let webpack = require('webpack');
let path = require('path');

module.exports = {
    entry: './resources/js/app.js',
    output: {
        path: path.resolve(__dirname, '/public/assets/js'),
        filename: 'bundle.js',
        publicPath: './public'
    },
    resolve: {
        alias: {
            'vue$': 'vue/dist/vue.common.js'
        }
    }
}

编译的结果是这样,我不禁认为警告是问题所在?

Hash: 4608a06553c30aeacdb5
Version: webpack 4.29.6
Time: 1037ms
Built at: 08/04/2019 09:39:50
    Asset     Size  Chunks                    Chunk Names
bundle.js  344 KiB       0  [emitted]  [big]  main
Entrypoint main [big] = bundle.js
 [1] (webpack)/buildin/global.js 472 bytes {0} [built]
[12] ./resources/js/app.js 1.17 KiB {0} [built]
[13] ./resources/js/bootstrap.js 1.7 KiB {0} [built]
[15] (webpack)/buildin/module.js 497 bytes {0} [built]
    + 35 hidden modules

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/

WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets: 
  bundle.js (344 KiB)

WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
  main (344 KiB)
      bundle.js


WARNING in webpack performance recommendations: 
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
For more info visit https://webpack.js.org/guides/code-splitting/

拥有这么大的Webpack不好吗?这是Laravel附带的版本,因此如果这个版本“太大”,我会被禁止添加任何其他内容?我希望这是一个配置,这不是一件坏事。

0 个答案:

没有答案