From 48ca9767f8a0d7aef38e654814c118bd89b16aa7 Mon Sep 17 00:00:00 2001 From: Dhinesh Date: Mon, 11 Nov 2019 12:15:39 +0530 Subject: [PATCH] Minor bug fixes --- .env | 0 .env.development | 0 config/environment/.env | 1 + config/environment/.env.development | 2 ++ config/environment/.env.production | 2 ++ config/webpack/paths.js | 5 +++-- config/webpack/rules.js | 17 ++++++----------- config/webpack/webpack.development.js | 11 ++++++++--- config/webpack/webpack.production.js | 7 ++++++- src/index.js | 1 + 10 files changed, 29 insertions(+), 17 deletions(-) delete mode 100644 .env delete mode 100644 .env.development create mode 100644 config/environment/.env create mode 100644 config/environment/.env.development create mode 100644 config/environment/.env.production diff --git a/.env b/.env deleted file mode 100644 index e69de29..0000000 diff --git a/.env.development b/.env.development deleted file mode 100644 index e69de29..0000000 diff --git a/config/environment/.env b/config/environment/.env new file mode 100644 index 0000000..16713d4 --- /dev/null +++ b/config/environment/.env @@ -0,0 +1 @@ +BASE_URL=http://localhost.base.com \ No newline at end of file diff --git a/config/environment/.env.development b/config/environment/.env.development new file mode 100644 index 0000000..680f542 --- /dev/null +++ b/config/environment/.env.development @@ -0,0 +1,2 @@ +BASE_URL=http://localhost.dev.com +BASE_URL_EXPAND=$BASE_URL/expanded \ No newline at end of file diff --git a/config/environment/.env.production b/config/environment/.env.production new file mode 100644 index 0000000..1ddd45d --- /dev/null +++ b/config/environment/.env.production @@ -0,0 +1,2 @@ +BASE_URL=http://localhost.prod.com +BASE_URL_EXPAND=$BASE_URL/expanded \ No newline at end of file diff --git a/config/webpack/paths.js b/config/webpack/paths.js index ba1d247..ceb361a 100755 --- a/config/webpack/paths.js +++ b/config/webpack/paths.js @@ -6,6 +6,7 @@ module.exports = { bundleReportPath: resolve(__dirname, '../', '../', 'dist', 'report.html'), entryPath: resolve(__dirname, '../', '../', 'src/index.js'), templatePath: resolve(__dirname, '../', '../', 'src/index.html'), - envDevPath: resolve(__dirname, '../', '../', '.env.development'), - envPath: resolve(__dirname, '../', '../', '.env') + envDevPath: resolve(__dirname, '../', 'environment', '.env.development'), + envProdPath: resolve(__dirname, '../', 'environment' , '.env.production'), + envPath: resolve(__dirname, '../', 'environment' , '.env'), }; diff --git a/config/webpack/rules.js b/config/webpack/rules.js index 593a79e..fa113b3 100755 --- a/config/webpack/rules.js +++ b/config/webpack/rules.js @@ -9,9 +9,7 @@ module.exports = [ loader: 'url-loader', options: { limit: fontInlineSizeLimit, - name: '[name].[ext]', - publicPath: '../fonts/', - outputPath: 'fonts/' + name: 'fonts/[name].[ext]', } }, { @@ -22,7 +20,8 @@ module.exports = [ options: { hmr: process.env.NODE_ENV === 'development', // if hmr does not work, this is a forceful method. - reloadAll: process.env.NODE_ENV === 'development' + reloadAll: process.env.NODE_ENV === 'development', + publicPath: '../' } }, { @@ -55,9 +54,7 @@ module.exports = [ loader: 'url-loader', options: { limit: imageInlineSizeLimit, - name: '[name].[hash:8].[ext]', - publicPath: '../images/', - outputPath: 'images/' + name: 'images/[name].[hash:8].[ext]', } } }, @@ -72,10 +69,8 @@ module.exports = [ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader', options: { - limit: 1000, - name: '[name].[hash:8].[ext]', - publicPath: '../images/', - outputPath: 'images/' + limit: imageInlineSizeLimit, + name: 'images/[name].[hash:8].[ext]', } } ]; diff --git a/config/webpack/webpack.development.js b/config/webpack/webpack.development.js index 2a31895..58526d2 100644 --- a/config/webpack/webpack.development.js +++ b/config/webpack/webpack.development.js @@ -28,8 +28,8 @@ module.exports = { exclude: /node_modules/, loader: 'eslint-loader', options: { - cache: true, - configFile: '.eslintrc.js', + cache: false, + configFile: './.eslintrc.js', emitWarning: true, // Fail only on errors failOnWarning: false, @@ -47,7 +47,12 @@ module.exports = { }, plugins: [ new Dotenv({ - path: paths.envDevPath // Path to .env file (this is the default) + path: paths.envDevPath, // Path to .env.development file + expand: true + }), + new Dotenv({ + path: paths.envPath, // Path to .env file + expand: true }), new MiniCssExtractPlugin({ filename: 'css/[name].css', diff --git a/config/webpack/webpack.production.js b/config/webpack/webpack.production.js index 32212a0..5ead870 100644 --- a/config/webpack/webpack.production.js +++ b/config/webpack/webpack.production.js @@ -18,7 +18,12 @@ module.exports = { new webpack.HashedModuleIdsPlugin(), // so that file hashes don't change unexpectedly new CleanWebpackPlugin(), new Dotenv({ - path: paths.envPath // Path to .env file (this is the default) + path: paths.envProdPath, // Path to .env.production file + expand: true + }), + new Dotenv({ + path: paths.envPath, // Path to .env file + expand: true }), new MiniCssExtractPlugin({ filename: 'css/[name]-[contenthash:8].css', diff --git a/src/index.js b/src/index.js index b2c857e..e2c345a 100644 --- a/src/index.js +++ b/src/index.js @@ -15,6 +15,7 @@ if (process.env.NODE_ENV !== 'production') { console.log('Looks like we are in development mode!'); } +console.log('Env var test ===>', process.env.BASE_URL, process.env.BASE_URL_EXPAND); // Wire up mithril app to DOM const $root = document.body.querySelector('#root'); m.route($root, DefaultRoute, Routes);