Skip to content

在多页面模式下,必须要src目录必须要有main.ts #2193

Closed
@ristona

Description

@ristona

Version

3.0.0

Node and OS info

OS:WIN10 YARN:v1.9.4

Steps to reproduce

1、在vue.config.js配置pages,配置如下:
pages: {
index: {
entry: 'src/pages/Index/main.ts',
template: 'src/pages/Index/template.html',
filename: 'index.html',
title: 'iot',
chunks: ['chunk-vendors', 'chunk-common', 'index']
},
// 当使用只有入口的字符串格式时,
// 模板会被推导为 public/subpage.html
// 并且如果找不到的话,就回退到 public/index.html
// 输出文件名会被推导为 subpage.html
subpage: 'src/subpage/main.js'
},
2、yarn build报错,错误如下:
This relative module was not found:

  • ./src/main.ts in multi ./src/main.ts

What is expected?

希望编译成功。说明下启用了typescript

What is actually happening?

真实结果:找不到src/mina


经查在https://github.com/vuejs/vue-cli/blob/483a08252e47075eaa492288e25ed2653f5f405d/packages/%40vue/cli-plugin-typescript/index.js有如下 代码片断:
api.chainWebpack(config => {
config.entry('app')
.clear()
.add('./src/main.ts')

应该判断如果已经为页面配置了entry,就不该添加默认入口文件。
目前,我只能通过添加一个空文件来回避这个BUG。
在与ts相关的tests也存在类似问题。

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions