diff --git a/package.json b/package.json index 57c14b2..5b71c77 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "private": true, "homepage": "https://github.com/EnixCoda/Gitako", "scripts": { - "start": "VERSION=dev-v$(node scripts/get-version.js) webpack --watch", + "dev": "VERSION=dev-v$(node scripts/get-version.js) webpack --watch", + "dev-safari": "TARGET=safari yarn run dev", "debug-firefox": "web-ext run -s dist", "analyse-bundle": "ANALYSE= NODE_ENV=production webpack", "postinstall": "rm -rf node_modules/@types/react-native && node scripts/fix-pjax-api", diff --git a/webpack.config.js b/webpack.config.js index b534407..c34aae7 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,6 +9,17 @@ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPl const srcPath = path.resolve(__dirname, 'src') const packagesPath = path.resolve(__dirname, 'packages') +function resolvePathInput(input) { + return path.isAbsolute(input) ? input : path.resolve(process.cwd(), input) +} + +const buildTarget = process.env.TARGET +const buildTargetOutputMap = { + safari: 'Safari/Gitako/Gitako Extension/Resources', +} +const envOutputDir = process.env.OUTPUT_DIR || buildTargetOutputMap[buildTarget] +const outputPath = envOutputDir ? resolvePathInput(envOutputDir) : path.resolve(__dirname, 'dist') + const IN_PRODUCTION_MODE = process.env.NODE_ENV === 'production' const plugins = [ new CopyWebpackPlugin([ @@ -24,6 +35,13 @@ const plugins = [ author, homepage_url, }) + + // Disable custom domains for Safari + if (buildTarget === 'safari') { + Reflect.deleteProperty(manifest, 'optional_permissions') + Reflect.deleteProperty(manifest, 'background') + } + if (!IN_PRODUCTION_MODE) { Object.assign(manifest, { web_accessible_resources: manifest.web_accessible_resources.concat('*.map'), // enable source mapping while developing @@ -75,7 +93,7 @@ module.exports = { devtool: IN_PRODUCTION_MODE ? 'source-map' : 'inline-source-map', mode: IN_PRODUCTION_MODE ? 'production' : 'development', output: { - path: path.resolve(__dirname, 'dist'), + path: outputPath, filename: '[name].js', }, resolve: {