Skip to content

期望可以设置htmlWebpackPlugin中的模板为pug模板 #2601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fengxinming opened this issue Sep 25, 2018 · 6 comments
Closed

期望可以设置htmlWebpackPlugin中的模板为pug模板 #2601

fengxinming opened this issue Sep 25, 2018 · 6 comments

Comments

@fengxinming
Copy link

What problem does this feature solve?

目前的index.html和多页配置的扩展名.html都是写死的,这样不方便迁移项目。因为项目初期都是用pug开发

What does the proposed API look like?

可以增加一个设置模板扩展名的参数。比如:.ext或者.extname之类的

@fengxinming
Copy link
Author

@sodatea you couldn't close this issues, because the last issues you didn't resolve and vue-cli 3.0 still does't support pug template

@haoqunjiang
Copy link
Member

yarn add -D pug-loader
// vue.config.js
module.exports = {
  pages: {
    app: {
      entry: resolve('./src/main.js'),
      template: 'public/index.pug',
      filename: 'index.html',
      title: 'vuecli3.0'
    }
  },
  chainWebpack: config =>
    config.module
      .rule('pug')
      .test(/\.pug$/)
        .uses
          .delete('pug-plain-loader')
          .end()
        .use('pug-loader')
          .loader('pug-loader')
}

@fengxinming
Copy link
Author

@sodatea

Look at the file ./node_modules/@vue/cli-service/lib/config/app.js

190 // resolve page index template
191 const hasDedicatedTemplate = fs.existsSync(api.resolve(template))
192 if (hasDedicatedTemplate) {
193 publicCopyIgnore.push(template)
194 }

The var hasDedicatedTemplate will be false when you use pug template

@haoqunjiang
Copy link
Member

It will be false when using webpack inline loader syntax like template: '!!pug-plain-loader!public/index.pug'. This issue is being tracked at #2697

But with the above-mentioned config you should have been able to use .pug files as templates.

@fengxinming
Copy link
Author

@sodatea what's the difference between pug-plain-loader and pug-loader?

@haoqunjiang
Copy link
Member

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

No branches or pull requests

2 participants