【问题标题】:Entry point - webpack.config.js vs vue.config.js入口点 - webpack.config.js vs vue.config.js
【发布时间】:2019-03-17 06:42:08
【问题描述】:

webpack.config.js文件中我们可以设置入口文件如下。

    module.exports = (env = {}, argv = {}) => {
        const config = {
            entry: {
                main: './src/js/main.js'                    
            },
        }
    }

但是在vue.config.js文件中,如何声明入口文件呢?我已签入doc。但是有这样的财产。

【问题讨论】:

    标签: vue.js webpack vuejs2 vue-cli-3


    【解决方案1】:

    Vue CLI 3 集成了 webpack-chain 库作为另一种配置 webpack 的方式。

    例如,您的配置文件可能如下所示:

    chainWebpack: config => {
      // clear the existing entry point
      config
        .entry('main')
          .clear()
    
      // add your custom entry point
      config
        .entry('main')
          .add('./src/js/main.js')
    }
    

    请参阅config entryPoints 部分。

    【讨论】:

    • 谢谢你。我们可以更改输出文件名吗?我使用outputDir 更改了输出目录名称。想要更改输出文件名。有什么办法改变吗?
    • 您可以使用config.output.path('dist').filename('[name].bundle.js'); 更改输出文件名。
    猜你喜欢
    • 2020-10-24
    • 2020-02-08
    • 2017-05-28
    • 1970-01-01
    • 2016-04-28
    • 1970-01-01
    • 2020-06-29
    • 2019-08-14
    • 2021-08-01
    相关资源
    最近更新 更多