Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #89 from doug-wade/issue-84
Browse files Browse the repository at this point in the history
[#84]: Add option to omit orientation
  • Loading branch information
doug-wade authored Dec 1, 2018
2 parents deb4a68 + 7cff1a3 commit 07ffbb7
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 4 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: node_js
node_js:
- "6"
- "8"
- "10"
- "node"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ If `inject: true` and `'theme-color'` property is not defined, it wil try to use

With `includeDirectory: true`, we will use `filename`'s directory to export the manifest file.

With `orientation: omit`, the orientation key will be omitted from the generated manifest file.

When `inject: true` and `ios: true`, specific Apple meta tags will be injected to the HTML code when possible, as requested at [issue #13](https://github.com/arthurbergmz/webpack-pwa-manifest/issues/13). You can see Apple's [Configuring Web Application](https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html) for more information. Instead of using a boolean value, you can also use an object to specify certain link or meta tag, for instance:

```javascript
Expand Down
3 changes: 3 additions & 0 deletions src/injector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ function createFilename (filenameTemplate, json, shouldFingerprint) {

function manifest (options, publicPath, icons, callback) {
const content = except(Object.assign({ icons }, options), ['filename', 'inject', 'fingerprints', 'ios', 'publicPath', 'icon', 'useWebpackPublicPath', 'includeDirectory', 'crossorigin'])
if (options.orientation === 'omit') {
delete content.orientation
}
const json = JSON.stringify(content, null, 2)
const file = path.parse(options.filename)
const filename = createFilename(file.base, json, options.fingerprints)
Expand Down
2 changes: 1 addition & 1 deletion src/validators/presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const presets = {
orientation: [
'any', 'natural', 'landscape', 'landscape-primary',
'landscape-secondary', 'portrait', 'portrait-primary',
'portrait-secondary'
'portrait-secondary', 'omit'
],
display: [
'fullscreen', 'standalone', 'minimal-ui', 'browser'
Expand Down
2 changes: 1 addition & 1 deletion tests/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const runTest = require('./runTest')
const tests = ['basic', 'complex', 'fingerprints-false', 'rgb-background', 'rgba-background']
const tests = ['basic', 'complex', 'fingerprints-false', 'issue-84', 'rgb-background', 'rgba-background']

console.log('Running tests...')
runTest(tests.shift(), tests)
2 changes: 2 additions & 0 deletions tests/issue-84/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
output/
Empty file added tests/issue-84/app.js
Empty file.
53 changes: 53 additions & 0 deletions tests/issue-84/build/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const WebpackPwaManifest = require('../../../dist')

module.exports = {
entry: path.join(__dirname, '../app.js'),
output: {
path: path.join(__dirname, '../output'),
publicPath: '/',
filename: '[name].[hash].bundle.js'
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
minify: {
minifyCSS: true,
minifyJS: true,
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
preserveLineBreaks: false,
removeAttributeQuotes: true,
removeComments: true
}
}),
new WebpackPwaManifest({
name: 'My Progressive Web App',
short_name: 'MyPWA',
description: 'My awesome Progressive Web App!',
background_color: '#ffffff',
orientation: 'omit',
ios: true,
icons: [
{
src: path.resolve('./tests/icon.png'),
sizes: 512,
destination: 'icons'
},
{
src: path.resolve('./tests/icon.png'),
size: 1024,
destination: 'icons',
ios: true
},
{
src: path.resolve('./tests/icon.svg'),
sizes: 512,
destination: 'icons',
color: '#ffffff'
}
]
})
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/issue-84/test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html><head><meta charset=UTF-8><title>Webpack App</title><meta name=apple-mobile-web-app-title content="My Progressive Web App"><meta name=apple-mobile-web-app-capable content=yes><meta name=apple-mobile-web-app-status-bar-style content=default><link rel=apple-touch-icon sizes=1024x1024 href=/icons/icon_1024x1024.9e29ee0667fc45a8662544c71ddd52ad.png><link rel=manifest href=/manifest.9b54133b3a32babd39ea99e4fee8daa1.json><link rel=mask-icon href=/icons/icon_512x512.dd60b11e9762b6e25f6d4ce981a1eeae.svg color=#ffffff></head><body><script type=text/javascript src=/main.72d5eaca4af91e626344.bundle.js></script></body></html>
1 change: 1 addition & 0 deletions tests/issue-84/test/main.72d5eaca4af91e626344.bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions tests/issue-84/test/manifest.9b54133b3a32babd39ea99e4fee8daa1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"icons": [
{
"src": "/icons/icon_512x512.dd60b11e9762b6e25f6d4ce981a1eeae.svg",
"sizes": "512x512",
"type": "image/svg+xml"
},
{
"src": "/icons/icon_1024x1024.9e29ee0667fc45a8662544c71ddd52ad.png",
"sizes": "1024x1024",
"type": "image/png"
},
{
"src": "/icons/icon_512x512.7da9f7ef24c6ad5fe248e7f62d5593a5.png",
"sizes": "512x512",
"type": "image/png"
}
],
"name": "My Progressive Web App",
"short_name": "MyPWA",
"display": "standalone",
"start_url": ".",
"description": "My awesome Progressive Web App!",
"background_color": "#ffffff"
}
2 changes: 1 addition & 1 deletion tests/runTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function run (name, next) {
run(next.shift(), next)
} else {
console.log('There are files missing or with different content.')
console.log(`Test "${name}" failed.`)
console.log(`Test "${name}" failedon file ${outputContent}.`)
assert(result === testContentLength)
}
} else {
Expand Down

0 comments on commit 07ffbb7

Please sign in to comment.