No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    CopyWebpackPlugin usage question

    Help
    4
    4
    3809
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      nobilik last edited by

      Hi! Can’t copy robots.txt on quasar build with CopyWebpackPlugin. I’ve just copy-paste from there, but there is an error:

      app:webpack Extending SPA Webpack config +493ms
      (node:15489) UnhandledPromiseRejectionWarning:   ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
         - options[0] misses the property 'patterns'. Should be:
           [non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
      

      What I’m doing wrong? Help pls!

      1 Reply Last reply Reply Quote 0
      • K
        kider last edited by

        Hi,
        Did you find the solution?
        I have the same problem and I still managed to find the solution.
        Thank you in advance.

        1 Reply Last reply Reply Quote 0
        • J
          jfabre last edited by jfabre

          This might be because you’ve updated to a newer version. What solved it for me was changing from:

              const CleanWebpackPlugin = require('clean-webpack-plugin');
          
              ...
              
              plugins: [
                  new CleanWebpackPlugin(),
                  new MiniCssExtractPlugin({
                      filename: "css/[name].bundle.css",
                      chunkFilename: "css/[name][id].bundle.css"
                  }),
                  new CopyWebpackPlugin([{
                      from: path.resolve(__dirname, '../src/static')
                  }])
              ],
          
          to:
              const { CleanWebpackPlugin } = require('clean-webpack-plugin');
          
              ...
          
              plugins: [
                  new CopyWebpackPlugin({
                      patterns: [
                          {from: path.resolve(__dirname, '../src/static')}
                      ]
                  })
              ],
          

          See: https://webpack.js.org/plugins/copy-webpack-plugin/

          1 Reply Last reply Reply Quote 0
          • E
            emmajnr last edited by emmajnr

            install robotstxt-webpack-plugin.js

            npm i robotstxt-webpack-plugin
            in your quasar.conf.js
            import

             const RobotstxtPlugin = require("robotstxt-webpack-plugin");
            const options = {
              filePath: "/robots.txt",
              policy: [
                {
                  userAgent: "*",
                  Allow: 'All',
                  crawlDelay: 30
                }
              ],
              sitemap: "https://example.com/sitemap.xml",
              host: "https://example.com"
            };
            
              build: {
                  scopeHoisting: true,
                  vueRouterMode: "history", // available values: 'hash', 'history'
                  showProgress: true,
                  gzip: false,
                  analyze: false,
                  // Options below are automatically set depending on the env, set them if you want to override
                  // preloadChunks: false,
                  extractCSS: true,
            
                  // https://quasar.dev/quasar-cli/cli-documentation/handling-webpack
                  extendWebpack(cfg) {
                    cfg.plugins.push(
                      new RobotstxtPlugin(options)
                    );
                  }
                },
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post