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.

flags: 'g' not working

See original GitHub issue

Hi

I’ve been trying to get string-replace-loader to work with the ‘g’ flag.

    loader: 'string-replace-loader',
    query: {
      search: 'REST_API',
      replace: 'test',
      flags: 'g'
    }

That doesn’t seem to work out. If I remove the ‘g’ flag and set ‘’ or ‘i’ as flag, it works perfectly. But ‘g’ flag always brings back the following error:

ERROR in ./~/css-loader?sourceMap!./~/vue-loader/lib/style-compiler?{"id":"data-v-84da6350","scoped":false,"hasInlineConfig":false}!./~/vue-loader/lib/selector.js?type=styles&index=0!./~/string-replace-loader?{"search":{},"replace":"test","flags":"g"}!./src/components/something/Test.vue
Module build failed: TypeError: Cannot read property 'content' of undefined
    at Object.module.exports (/home/inzanez/WebDevel/testapp/node_modules/vue-loader/lib/selector.js:18:27)
 @ ./~/vue-style-loader!./~/css-loader?sourceMap!./~/vue-loader/lib/style-compiler?{"id":"data-v-84da6350","scoped":false,"hasInlineConfig":false}!./~/vue-loader/lib/selector.js?type=styles&index=0!./~/string-replace-loader?{"search":{},"replace":"test","flags":"g"}!./src/components/something/Test.vue 4:14-409 13:3-17:5 14:22-417
 @ ./src/components/something/Test.vue
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

Any idea what might be wrong here?oO

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Va1commented, Feb 25, 2018

sorry for the delayed reply. this was caused by the bug when options being overwritten, while they should remain immutable. fixed in v2.0.0 released recently

1reaction
shirishpcommented, Jul 12, 2017

@derekshull @inzanez I have created a new issue with a possible workaround - https://github.com/Va1/string-replace-loader/issues/31

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does a RegExp with global flag give wrong results?
A RegExp object with the g flag keeps track of the lastIndex where a match occurred, so on subsequent matches it will start...
Read more >
sed "e" and "g" flags not working together - Unix Stack Exchange
The flags work together in the opposite way to what you're expecting. The documentation of /e is, for the record:.
Read more >
Patterns and flags - The Modern JavaScript Tutorial
A regular expression consists of a pattern and optional flags: g , i , m , u , s , y . Without...
Read more >
Optimize Options (Using the GNU Compiler Collection (GCC))
Turning on optimization flags makes the compiler attempt to improve the performance and/or code size at the expense of compilation time and possibly...
Read more >
Understanding and Using Makefile Flags - Earthly Blog
But let's say that you do not wish to pass the -Wall option; ... CC = gcc CFLAGS = -g # Flag to...
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