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

Commit

Permalink
update pwa
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonxiang committed Oct 15, 2017
1 parent 92ed8f5 commit 6598447
Show file tree
Hide file tree
Showing 71 changed files with 2,291 additions and 1,323 deletions.
8 changes: 6 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"presets": [
["env", { "modules": false }],
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-runtime"],
"comments": false,
"env": {
"test": {
"presets": ["env", "stage-2"],
Expand Down
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/*.js
config/*.js
39 changes: 39 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// http://eslint.org/docs/user-guide/configuring

module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
env: {
browser: true,
},
extends: 'airbnb-base',
// required to lint *.vue files
plugins: [
'html'
],
// check if imports actually resolve
'settings': {
'import/resolver': {
'webpack': {
'config': 'build/webpack.base.conf.js'
}
}
},
// add your custom rules here
'rules': {
// don't require .vue extension when importing
'import/extensions': ['error', 'always', {
'js': 'never',
'vue': 'never'
}],
// allow optionalDependencies
'import/no-extraneous-dependencies': ['error', {
'optionalDependencies': ['test/unit/index.js']
}],
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
}
}
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
.DS_Store
node_modules/
dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
*.suo
*.ntvs*
*.njsproj
*.sln

# Logs
logs
*.log
Expand Down
7 changes: 1 addition & 6 deletions .postcssrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
module.exports = {
"plugins": {
// to edit target browsers: use "browserlist" field in package.json
"autoprefixer": {},
"postcss-pxtorem": {
root_value: 20, // 基准值 html{ font-zise: 20px; }
prop_white_list: [], // 对所有 px 值生效
minPixelValue: 2 // 忽略 1px 值
}
"autoprefixer": {}
}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ npn run build

## DEMO

[DEMO](https://www.shanww.cc/app/)

[PC DEMO](https://brandonxiang.github.io/vue-leaflet-mobile/www/)

![Phone DEMO](screen/demo.png)
Expand Down
2 changes: 1 addition & 1 deletion build/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var devMiddleware = require('webpack-dev-middleware')(compiler, {
})

var hotMiddleware = require('webpack-hot-middleware')(compiler, {
log: () => {}
log: false
})
// force page reload when html-webpack-plugin template changes
compiler.plugin('compilation', function (compilation) {
Expand Down
9 changes: 9 additions & 0 deletions build/load-minified.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var fs = require('fs')
var UglifyJS = require('uglify-es')

module.exports = function(filePath) {
var code = fs.readFileSync(filePath, 'utf-8')
var result = UglifyJS.minify(code)
if (result.error) return ''
return result.code
}
8 changes: 7 additions & 1 deletion build/vue-loader.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ module.exports = {
? config.build.productionSourceMap
: config.dev.cssSourceMap,
extract: isProduction
})
}),
transformToRequire: {
video: 'src',
source: 'src',
img: 'src',
image: 'xlink:href'
}
}
8 changes: 8 additions & 0 deletions build/webpack.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ const webpackConfig = {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
}
]
}
Expand Down
5 changes: 3 additions & 2 deletions build/webpack.prod.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
var SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin')
var loadMinified = require('./load-minified')

var env = config.build.env

Expand Down Expand Up @@ -64,8 +65,8 @@ var webpackConfig = merge(baseWebpackConfig, {
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency',
serviceWorkerLoader: `<script>${fs.readFileSync(path.join(__dirname,
'./service-worker-prod.js'), 'utf-8')}</script>`
serviceWorkerLoader: `<script>${loadMinified(path.join(__dirname,
'./service-worker-prod.js'))}</script>`
}),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
Expand Down
17 changes: 10 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
<!DOCTYPE html>
<html data-rem="375">
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>vue-leaflet-mobile</title>
<link rel="icon" type="image/png" sizes="32x32" href="static/img/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="static/img/icons/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="<%= htmlWebpackPlugin.files.publicPath %>static/img/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="<%= htmlWebpackPlugin.files.publicPath %>static/img/icons/favicon-16x16.png">
<!--[if IE]><link rel="shortcut icon" href="/static/img/icons/favicon.ico"><![endif]-->
<!-- Add to home screen for Android and modern mobile browsers -->
<link rel="manifest" href="static/manifest.json">
<link rel="manifest" href="<%= htmlWebpackPlugin.files.publicPath %>static/manifest.json">
<meta name="theme-color" content="#4DBA87">

<!-- Add to home screen for Safari on iOS -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="vue-leaflet-mobile">
<link rel="apple-touch-icon" href="static/img/icons/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" href="<%= htmlWebpackPlugin.files.publicPath %>static/img/icons/apple-touch-icon-152x152.png">
<!-- Add to home screen for Windows -->
<meta name="msapplication-TileImage" content="static/img/icons/msapplication-icon-144x144.png">
<meta name="msapplication-TileImage" content="<%= htmlWebpackPlugin.files.publicPath %>static/img/icons/msapplication-icon-144x144.png">
<meta name="msapplication-TileColor" content="#000000">
<% for (var chunk of webpack.chunks) {
for (var file of chunk.files) {
if (file.match(/\.(js|css)$/)) { %>
<link rel="<%= chunk.initial?'preload':'prefetch' %>" href="<%= htmlWebpackPlugin.files.publicPath + file %>" as="<%= file.match(/\.css$/)?'style':'script' %>"><% }}} %>
</head>
<body>
<div id="app">This is your fallback content in case JavaScript fails to load.</div>
<noscript>
This is your fallback content in case JavaScript fails to load.
</noscript>
<div id="app"></div>
<!-- Todo: only include in production -->
<%= htmlWebpackPlugin.options.serviceWorkerLoader %>
<!-- built files will be auto injected -->
Expand Down
Loading

0 comments on commit 6598447

Please sign in to comment.