Add polyfills and prod build

This commit is contained in:
Antti Pilto 2018-11-17 01:19:55 +02:00
parent 4ff4815c34
commit f5067832d6
4 changed files with 98 additions and 2 deletions

View File

@ -1,4 +1,7 @@
{
"presets" : ["@babel/preset-env", "@babel/preset-react"],
"presets" : [
["@babel/preset-env", { "useBuiltIns": "usage" }],
"@babel/preset-react"
],
"plugins": ["@babel/plugin-proposal-class-properties"]
}

21
package-lock.json generated
View File

@ -919,6 +919,27 @@
}
}
},
"@babel/polyfill": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/@babel/polyfill/-/polyfill-7.0.0.tgz",
"integrity": "sha512-dnrMRkyyr74CRelJwvgnnSUDh2ge2NCTyHVwpOdvRMHtJUyxLtMAfhBN3s64pY41zdw0kgiLPh6S20eb1NcX6Q==",
"requires": {
"core-js": "^2.5.7",
"regenerator-runtime": "^0.11.1"
},
"dependencies": {
"core-js": {
"version": "2.5.7",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz",
"integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw=="
},
"regenerator-runtime": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg=="
}
}
},
"@babel/preset-env": {
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.1.6.tgz",

View File

@ -7,7 +7,7 @@
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --open --mode development --host 0.0.0.0 --config webpack.config.js",
"mobile": "webpack-dev-server --open --mode development --host 0.0.0.0 --public 192.168.1.8:8080",
"build": "webpack --mode production"
"build": "webpack --mode production --config webpack.config.prod.js"
},
"repository": {
"type": "git",
@ -19,6 +19,10 @@
"url": "https://github.com/anzzstuff/kanaquiz/issues"
},
"homepage": "https://github.com/anzzstuff/kanaquiz#readme",
"browserslist": [
"> 0.25%",
"not dead"
],
"devDependencies": {
"@babel/core": "^7.1.6",
"@babel/plugin-proposal-class-properties": "^7.1.0",
@ -41,6 +45,7 @@
"webpack-dev-server": "^3.1.10"
},
"dependencies": {
"@babel/polyfill": "^7.0.0",
"prop-types": "^15.6.2",
"react": "^16.6.3",
"react-dom": "^16.6.3",

67
webpack.config.prod.js Normal file
View File

@ -0,0 +1,67 @@
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const path = require('path');
module.exports = {
context: __dirname,
output: {
path: path.resolve(__dirname, './dist'),
publicPath: './dist/',
filename: 'bundle.js'
},
resolve: {
extensions: ['.js', '.jsx']
},
plugins: [
new SWPrecacheWebpackPlugin( {
cacheId: 'kana-quiz',
filename: 'sw.js',
stripPrefix: '/home/anzz/code/kanaquiz/',
maximumFileSizeToCacheInBytes: 4194304,
minify: true,
runtimeCaching: [{
handler: 'networkFirst',
urlPattern: /\.(woff2|svg|ttf|eot|woff|html)$/,
}],
})
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.scss$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
importLoaders: 1
}
},
{
loader: 'postcss-loader'
}
]
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(png|jpg|svg|woff|woff2)?(\?v=\d+.\d+.\d+)?$/,
loader: 'url-loader?limit=25000'
},
{
test: /\.(eot|ttf)$/,
loader: 'file-loader'
}
]
}
};