diff --git a/.dev.sample.json b/.dev.sample.json new file mode 100644 index 0000000..67bf186 --- /dev/null +++ b/.dev.sample.json @@ -0,0 +1,4 @@ +{ + "DEFAULT_API_URL": "https://app.simplelogin.io", + "permissions": [] +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index a9a723f..3e45587 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ /dist /dist-zip .DS_Store -.idea/ \ No newline at end of file +.idea/ +.dev.json \ No newline at end of file diff --git a/src/popup/SLStorage.js b/src/popup/SLStorage.js index 4da2e20..29fa66f 100644 --- a/src/popup/SLStorage.js +++ b/src/popup/SLStorage.js @@ -8,7 +8,9 @@ class SLStorage { }; static DEFAULT_SETTINGS = { - [SLStorage.SETTINGS.API_URL]: "https://app.simplelogin.io", + [SLStorage.SETTINGS.API_URL]: devConfig + ? devConfig.DEFAULT_API_URL + : "https://app.simplelogin.io", [SLStorage.SETTINGS.API_KEY]: "", [SLStorage.SETTINGS.NOT_ASKING_RATE]: false, }; diff --git a/webpack.config.js b/webpack.config.js index a9aa0bb..19eb166 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,6 +5,11 @@ const CopyWebpackPlugin = require('copy-webpack-plugin'); const ExtensionReloader = require('webpack-extension-reloader'); const { VueLoaderPlugin } = require('vue-loader'); const { version } = require('./package.json'); +const fs = require('fs'); + +const devConfig = fs.existsSync('./.dev.json') + ? JSON.parse(fs.readFileSync('./.dev.json').toString()) + : JSON.parse(fs.readFileSync('./.dev.sample.json').toString()); const config = { mode: process.env.NODE_ENV, @@ -91,6 +96,7 @@ const config = { if (config.mode === 'development') { jsonContent['content_security_policy'] = "script-src 'self' 'unsafe-eval'; object-src 'self'"; + jsonContent['permissions'] = jsonContent['permissions'].concat(devConfig.permissions); } return JSON.stringify(jsonContent, null, 2); @@ -100,6 +106,14 @@ const config = { ], }; +if (config.mode === 'development') { + config.plugins = (config.plugins || []).concat([ + new webpack.DefinePlugin({ + devConfig: JSON.stringify(devConfig), + }), + ]); +} + if (config.mode === 'production') { config.plugins = (config.plugins || []).concat([ new webpack.DefinePlugin({ @@ -121,6 +135,7 @@ if (process.env.HMR === 'true') { function transformHtml(content) { return ejs.render(content.toString(), { ...process.env, + devConfig, }); }