Akryum / vue-cli-plugin-ssr

:sparkles: Simple SSR plugin for Vue CLI
https://vue-cli-plugin-ssr.netlify.com/
MIT License
444 stars 69 forks source link

registerServiceWorker import not being removed from main.js when using semicolons #24

Open Narkoleptika opened 6 years ago

Narkoleptika commented 6 years ago

Hello, another quick fix here.

When invoking this plugin in a project with the pwa plugin and an eslint config that uses semicolons, the registerServiceWorker import line is not removed from main.js.

This can be resolved by doing this

-contents = contents.replace(/import ('|")\.\/registerServiceWorker('|")\n/, ``)
+contents = contents.replace(/import ('|")\.\/registerServiceWorker('|");?\n/, ``)

Here https://github.com/Akryum/vue-cli-plugin-ssr/blob/master/generator/index.js#L47

beeplin commented 6 years ago

have the same situation too. It fails to remove import './registerServiceWorker'; due to the semicolon and the whole ssr:build & ssr:start fails to work. I have to manually remove the import line.