esnunes / riotjs-loader

riotjs module loader for webpack
MIT License
103 stars 41 forks source link

About external script file #16

Open cncolder opened 8 years ago

cncolder commented 8 years ago

Since I have sent a pull request https://github.com/esnunes/riotjs-loader/pull/15 about compile external script file. But I still have a question. I need tell webpack our tag file dependency that external js file. So that webpack should recompile in watch mode after I save my js file.

I can't find a good way to do that. I have some ugly code in my own usage. Use regex match source string then add dependency it.

    var match = /<script.*?src="(.*?)"/gmi.exec(source)
    if (match) {
      let script = path.resolve(path.dirname(this.resourcePath), match[1])
      this.dependency(script)
    }

If someone thinking this is acceptable or provide a better regex. I can make this loader work better.