What is the right way to set a different <base> for dev/staging/production

前端 未结 6 600
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-10 01:07

for dev and production are different(for production it\'s subfolder). What is the good way to build different base with webp

6条回答
  •  一个人的身影
    2020-12-10 01:38

    In Webpack 4 I have tried the baseUrl in HtmlWebpackPlugin , but it's never gets parsed in the html. So you need a new plugin called BaseHredWebpackPlugin along with HtmlWebpackPlugin

    Webpack.config

     new HtmlWebpackPlugin(), //this will create default template
            new HtmlWebpackPlugin({
                title: 'MyApp' //replace title
    
            }),
            new BaseHrefWebpackPlugin({
                baseHref: process.env.NODE_ENV == 'development' ? '/' : '/MyApp/'
            })
    

    Html

        
        <%= htmlWebpackPlugin.options.title %>
    

提交回复
热议问题