mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
build: add webpack build support for Safari
This commit is contained in:
parent
7ab1c95b99
commit
c9c968aa2c
2 changed files with 21 additions and 2 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue