From 79805945cc46ee1f5558e1f79b33a89c4b47e15f Mon Sep 17 00:00:00 2001 From: Antti Pilto Date: Fri, 16 Nov 2018 20:06:14 +0200 Subject: [PATCH] 1st commit --- .babelrc | 5 ++- package.json | 24 +++++++------- webpack.config.js | 68 +++++++------------------------------- webpack.config.prod.js | 75 ------------------------------------------ 4 files changed, 26 insertions(+), 146 deletions(-) delete mode 100644 webpack.config.prod.js diff --git a/.babelrc b/.babelrc index 33fe176..7b4f9e4 100644 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,3 @@ { - "presets" : ["es2015", "react"], - "plugins" : ["transform-object-assign"] -} \ No newline at end of file + "presets" : ["@babel/preset-env", "@babel/preset-react"], +} diff --git a/package.json b/package.json index 4408409..f71eef0 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,9 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "start": "webpack-dev-server --host 0.0.0.0", - "mobile": "webpack-dev-server --host 0.0.0.0 --public 192.168.1.8:8080", - "build": "webpack -p --config webpack.config.prod.js" + "start": "webpack-dev-server --open --mode development --host 0.0.0.0", + "mobile": "webpack-dev-server --open --mode development --host 0.0.0.0 --public 192.168.1.8:8080", + "build": "webpack --mode production" }, "repository": { "type": "git", @@ -20,24 +20,24 @@ }, "homepage": "https://github.com/anzzstuff/kanaquiz#readme", "devDependencies": { + "@babel/core": "^7.1.2", + "@babel/preset-env": "^7.1.0", + "@babel/preset-react": "^7.0.0", "autoprefixer": "^6.3.7", - "babel-core": "^6.24.0", - "babel-loader": "^6.2.4", - "babel-plugin-transform-object-assign": "^6.22.0", - "babel-preset-es2015": "^6.9.0", - "babel-preset-react": "^6.11.1", + "babel-loader": "^8.0.4", "css-loader": "^0.27.3", "file-loader": "^0.10.1", - "html-webpack-plugin": "^2.22.0", + "html-webpack-plugin": "^3.2.0", "postcss": "^5.0.21", "postcss-loader": "^1.3.3", "precss": "^1.4.0", "react-hot-loader": "^1.3.0", "style-loader": "^0.14.1", - "sw-precache-webpack-plugin": "^0.10.1", + "sw-precache-webpack-plugin": "^0.11.5", "url-loader": "^0.5.7", - "webpack": "^2.2.1", - "webpack-dev-server": "^2.4.2" + "webpack": "^4.24.0", + "webpack-cli": "^3.1.2", + "webpack-dev-server": "^3.1.10" }, "dependencies": { "postcss": "^5.1.0", diff --git a/webpack.config.js b/webpack.config.js index 4cb388a..84bf406 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,57 +1,13 @@ -const webpack = require('webpack'); -const fs = require('fs'); -const path = require('path'); -const autoprefixer = require('autoprefixer'); -const precss = require('precss'); -const HtmlWebPackPlugin = require('html-webpack-plugin'); - module.exports = { - entry: [ - 'webpack-dev-server/client?http://localhost:8080', - 'webpack/hot/only-dev-server', // "only" prevents reload on syntax errors - './src/index' - ], - output: { - path: path.resolve(__dirname, './dist'), - publicPath: '/', - filename: 'bundle.js' - }, - resolve: { - extensions: ['.js', '.jsx'] - }, - plugins: [ - new HtmlWebPackPlugin({ - template: 'src/index.html', - filename: './index.html' - }), - new webpack.HotModuleReplacementPlugin(), - new webpack.LoaderOptionsPlugin({ - options: { - postcss: function() { - return [autoprefixer, precss]; - } - } - }) - ], - module: { - loaders: [ - { - test: /\.jsx?$/, - exclude: /node_modules/, - loaders: ['react-hot-loader', 'babel-loader'] - }, { - test: /\.scss$/, - loaders: ['style-loader', 'css-loader', 'postcss-loader'] - }, { - test: /\.css$/, - loaders: ['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' - } - ] - } -}; \ No newline at end of file + module: { + rules: [ + { + test: /\.js$/, + exclude: /node_modules/, + use: { + loader: "babel-loader" + } + } + ] + } +}; diff --git a/webpack.config.prod.js b/webpack.config.prod.js deleted file mode 100644 index 04b6c8d..0000000 --- a/webpack.config.prod.js +++ /dev/null @@ -1,75 +0,0 @@ -const webpack = require('webpack'); -const fs = require('fs'); -const path = require('path'); -const autoprefixer = require('autoprefixer'); -const precss = require('precss'); -const HtmlWebPackPlugin = require('html-webpack-plugin'); -const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin'); - -module.exports = { - context: __dirname, - devtool: 'cheap-module-source-map', - entry: [ - './src/index' - ], - output: { - path: path.resolve(__dirname, './dist'), - publicPath: './dist/', - filename: 'bundle.js' - }, - resolve: { - extensions: ['.js', '.jsx'] - }, - plugins: [ - new HtmlWebPackPlugin({ - template: 'src/index.html', - filename: '../index.html' - }), - new webpack.optimize.UglifyJsPlugin({ - sourceMap: true, - compress:{ - warnings: false - }, - }), - new webpack.NoEmitOnErrorsPlugin(), - new webpack.LoaderOptionsPlugin({ - options: { - postcss: function() { - return [autoprefixer, precss]; - } - } - }), - 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: { - loaders: [ - { - test: /\.jsx?$/, - exclude: /node_modules/, - loaders: ['babel-loader'] - }, { - test: /\.scss$/, - loaders: ['style-loader', 'css-loader', 'postcss-loader'] - }, { - test: /\.css$/, - loaders: ['style-loader', 'css-loader'] - }, { - test: /\.(png|jpg|svg|woff|woff2)?(\?v=\d+.\d+.\d+)?$/, - loader: 'url-loader?limit=8192' - }, { - test: /\.(eot|ttf)$/, - loader: 'file-loader' - } - ] - } -};