question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

config `pages` do not support to specify template loader

See original GitHub issue

Version

3.5.0

Environment info

  System:
    OS: macOS 10.14.4
    CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
  Binaries:
    Node: 10.15.1 - /usr/local/bin/node
    Yarn: 1.12.3 - /usr/local/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 74.0.3729.131
    Firefox: Not Found
    Safari: 12.1
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0-beta.3 
    @vue/babel-plugin-transform-vue-jsx:  1.0.0-beta.3 
    @vue/babel-preset-app:  3.5.3 
    @vue/babel-preset-jsx:  1.0.0-beta.3 
    @vue/babel-sugar-functional-vue:  1.0.0-beta.3 
    @vue/babel-sugar-inject-h:  1.0.0-beta.3 
    @vue/babel-sugar-v-model:  1.0.0-beta.3 
    @vue/babel-sugar-v-on:  1.0.0-beta.3 
    @vue/cli-overlay:  3.5.1 
    @vue/cli-plugin-babel: ^3.5.0 => 3.5.3 
    @vue/cli-plugin-e2e-nightwatch: ^3.5.0 => 3.5.1 
    @vue/cli-plugin-eslint: ^3.5.0 => 3.5.1 
    @vue/cli-plugin-unit-jest: ^3.5.3 => 3.5.3 
    @vue/cli-service: ^3.5.0 => 3.5.3 
    @vue/cli-shared-utils:  3.5.1 
    @vue/component-compiler-utils:  2.6.0 
    @vue/eslint-config-prettier: ^4.0.1 => 4.0.1 
    @vue/preload-webpack-plugin:  1.1.0 
    @vue/test-utils: 1.0.0-beta.29 => 1.0.0-beta.29 
    @vue/web-component-wrapper:  1.2.0 
    eslint-plugin-vue: ^5.0.0 => 5.2.2 
    jest-serializer-vue:  2.0.2 
    vue: ^2.6.6 => 2.6.10 
    vue-eslint-parser:  2.0.3 
    vue-hot-reload-api:  2.3.3 
    vue-jest:  3.0.4 
    vue-loader:  15.7.0 
    vue-router: ^3.0.1 => 3.0.2 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.5.21 => 2.6.10 
    vue-template-es2015-compiler:  1.9.1 
  npmGlobalPackages:
    @vue/cli: 3.5.1

Steps to reproduce

  • config with pages option
pages: {
    index: {
        entry: 'src/pages/home/index.js',
        template: 'public/index.html',
        filename: 'index.shtml',
        chunks: ['chunk-vendors', 'chunk-common', 'index'],
        minify: false
    },
    about: {
        entry: 'src/pages/about/index.js',
        template: `!!${path.resolve(__dirname, './lib/loader/html.js')}!${'about.shtml'}`,
        filename: 'about.shtml',
        chunks: ['chunk-vendors', 'chunk-common', 'about'],
        minify: false
    }
}
  • run vue inspect > ./webpack.config.js
  • check webpack.config.js

What is expected?

should get config like below

    /* config.plugin('html-about') */
    new HtmlWebpackPlugin(
      {
        templateParameters: function () { /* omitted long function */ },
        chunks: [
          'chunk-vendors',
          'chunk-common',
          'about'
        ],
        template: '!!/path/to/loader/html.js!/path/to/about.html',
        filename: 'about.shtml',
        minify: false
      }
    ),

What is actually happening?

new HtmlWebpackPlugin(
      {
        templateParameters: function () { /* omitted long function */ },
        chunks: [
          'chunk-vendors',
          'chunk-common',
          'about'
        ],
        template: '/path/to/node_modules/@vue/cli-service/lib/config/index-default.html',
        filename: 'about.shtml',
        minify: false
      }
    )

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
funkyLovercommented, May 31, 2019

find a way to avoid this situation.

const pages = {
    app: {
        entry: 'src/app.js',
        template: 'public/index.shtml'
    },
    about: {
        entry: 'src/about.js',
        template: 'public/about.shtml'
    }
};

module.exports = {
    pages: pages,
    chainWebpack: config => {
        Object.keys(pages).forEach(key => {
               config.plugin(`html-${key}`).tap(args => {
                    if (!args || args.length === 0) return args;
                    args[0].template = `!!/path/to/loader!${args[0].template}`;
                    return args;
                });
        });
    }
}
0reactions
lisiyizucommented, Aug 24, 2019

find a way to avoid this situation.

const pages = {
    app: {
        entry: 'src/app.js',
        template: 'public/index.shtml'
    },
    about: {
        entry: 'src/about.js',
        template: 'public/about.shtml'
    }
};

module.exports = {
    pages: pages,
    chainWebpack: config => {
        Object.keys(pages).forEach(key => {
               config.plugin(`html-${key}`).tap(args => {
                    if (!args || args.length === 0) return args;
                    args[0].template = `!!/path/to/loader!${args[0].template}`;
                    return args;
                });
        });
    }
}

感谢,我也遇到了这个问题,🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Usage of ConfigPages | Config Pages - Drupal
Load entire ConfigPage entities. You have three ways to do that, the best way (Drupal 8+) is to either inject or side-load the...
Read more >
Django TemplateDoesNotExist? - python - Stack Overflow
First solution: These settings. TEMPLATE_DIRS = ( os.path.join(SETTINGS_PATH, 'templates'), ). mean that Django will look at the templates from templates/ ...
Read more >
Template loading - Apache FreeMarker Manual
Template loaders. Template loaders are objects that load raw textual data based on abstract template paths like "index.ftl" or ...
Read more >
Load or unload a template or add-in program - Microsoft Support
If you quit and then restart Word, the template or add-in is not automatically reloaded. In Word 2010, 2013, or 2016, select File...
Read more >
API — Jinja Documentation (3.0.x)
The simplest way to configure Jinja to load templates for your application is to use PackageLoader . from jinja2 import Environment, PackageLoader, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found