Browse Source

fix: updated webpack

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 5 years ago
parent
commit
7971274c6d
6 changed files with 3433 additions and 1504 deletions
  1. 0 46
      dist/lofig.min.js
  2. 4 4
      example/index.html
  3. 6 8
      lofig.js
  4. 3399 1419
      package-lock.json
  5. 16 12
      package.json
  6. 8 15
      webpack.config.js

File diff suppressed because it is too large
+ 0 - 46
dist/lofig.min.js


+ 4 - 4
example/index.html

@@ -7,13 +7,13 @@
 <body>
 	<h3>
 		Secret:
-		<span></span>
+		<span id="secret"></span>
 	</h3>
 	<script src="../dist/lofig.min.js"></script>
 	<script>
-		(async function () {
-			console.log(await(lofig.has('secret')));
-			console.log(await lofig.get('secret'));
+		(async () => {
+			document.getElementById("secret").textContent = await lofig.get('secret');
+			document.getElementById("secret").style.color = "tomato";
 		})();
 	</script>
 </body>

+ 6 - 8
lofig.js

@@ -1,5 +1,3 @@
-import 'bluebird';
-import 'whatwg-fetch';
 
 window.lofig = {
 	folder: 'config/default.json',
@@ -8,12 +6,12 @@ window.lofig = {
 			.then(response => {
 				return response.json();
 			}).then(json => {
-				query = query.split('.');
-				return Promise.each(query, property => {
-					json = json[property];
-				}).then(() => {
-					return json;
-				});
+				query.split('.')
+					.forEach(property => {
+						json = json[property];
+					});
+
+				return json;
 			}).catch(err => {
 				console.log('parsing failed', err);
 			});

File diff suppressed because it is too large
+ 3399 - 1419
package-lock.json


+ 16 - 12
package.json

@@ -4,20 +4,23 @@
     "url": "https://github.com/jonathan-grah/lofig/issues"
   },
   "dependencies": {
-    "whatwg-fetch": "^2.0.1"
+    "whatwg-fetch": "^3.0.0"
   },
   "description": "Like the Config package, but for client side JavaScript",
   "devDependencies": {
-    "babel-cli": "^6.18.0",
-    "babel-core": "^6.20.0",
-    "babel-loader": "^6.2.9",
-    "babel-polyfill": "^6.20.0",
-    "babel-preset-es2015": "^6.18.0",
-    "bluebird": "^3.4.6",
-    "exports-loader": "^0.6.3",
-    "imports-loader": "^0.7.0",
-    "webpack": "^1.14.0",
-    "webpack-dev-server": "^1.12.1"
+    "@babel/core": "^7.6.0",
+    "@babel/preset-env": "^7.6.0",
+    "babel-cli": "^6.26.0",
+    "babel-core": "^6.26.3",
+    "babel-loader": "^8.0.6",
+    "babel-polyfill": "^6.26.0",
+    "babel-preset-es2015": "^6.24.1",
+    "bluebird": "^3.5.5",
+    "exports-loader": "^0.7.0",
+    "imports-loader": "^0.8.0",
+    "webpack": "^4.28.4",
+    "webpack-cli": "^3.3.8",
+    "webpack-dev-server": "^3.8.0"
   },
   "homepage": "https://github.com/jonathan-grah/lofig",
   "license": "MIT",
@@ -28,7 +31,8 @@
     "url": "git+https://github.com/jonathan-grah/lofig.git"
   },
   "scripts": {
-    "dev": "webpack-dev-server --inline --hot --content-base example"
+    "dev": "webpack-dev-server --inline --hot --content-base example",
+    "build": "webpack --mode=production"
   },
   "version": "1.1.2"
 }

+ 8 - 15
webpack.config.js

@@ -2,7 +2,7 @@ var path = require('path')
 var webpack = require('webpack')
 
 module.exports = {
-  entry: './lofig.js',
+  entry: ['./lofig.js'],
   output: {
     path: path.resolve(__dirname, './dist'),
     publicPath: '/dist',
@@ -13,17 +13,16 @@ module.exports = {
       modules: path.join(__dirname, 'node_modules')
     }
   },
-  resolveLoader: {
-    root: path.join(__dirname, 'node_modules'),
-  },
   module: {
-    loaders: [
+    rules: [
       {
         test: /\.js$/,
-        loader: 'babel',
         exclude: /node_modules/,
-        query: {
-            presets: ['es2015']
+        use: {
+            loader: 'babel-loader',
+            options: {
+                presets: ['@babel/preset-env']
+            }
         }
       }
     ]
@@ -32,13 +31,7 @@ module.exports = {
     historyApiFallback: true,
     noInfo: true
   },
-  devtool: '#eval-source-map',
-  plugins: [
-    new webpack.ProvidePlugin({
-        'Promise': 'bluebird',
-        'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
-    }),
-  ]
+  devtool: '#eval-source-map'
 }
 
 if (process.env.NODE_ENV === 'production') {

Some files were not shown because too many files changed in this diff