Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

开发环境访问路径问题 #10

Open
wbcz opened this issue Aug 27, 2017 · 1 comment
Open

开发环境访问路径问题 #10

wbcz opened this issue Aug 27, 2017 · 1 comment

Comments

@wbcz
Copy link

wbcz commented Aug 27, 2017

config.plugins.push(
    new HtmlWebpackPlugin({
        chunks: ['vendor', entry],
        filename: entry + '/index.html',
        template: 'src/template/index.html',
        inject: true
    })
)

我更改了下打包生成目录的结构如下
index
--- index.html
module1
--- index.html
但是在开发环境的时候访问的时候必须是http://localhost:8082/module/index.html
但是当我打包到生产的时候,却只需要http://xxx.com/module就可以了
所以你有什么办法可以在开发环境也通过http://localhost:8082/module能访问得到么

@lincenying
Copy link
Owner

lincenying commented Aug 27, 2017

build/dev-server.js 里重写下路径.

app.use(require('connect-history-api-fallback')({
    rewrites: [
      { from: /\/index$/, to: '/index/index.html'},
      { from: /\/module2$/, to: '/module2/index.html'},
      // .....
    ]
}))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants