From dc470c1d2c0133ac2cb1b70ac37f1a3a9b60a6ca Mon Sep 17 00:00:00 2001 From: Pranav Raj Sreepuram Date: Wed, 21 Aug 2019 21:30:25 +0530 Subject: [PATCH 1/2] Set webpack_compile_output to true --- config/webpack/development.js | 11 ++++++----- config/webpacker.yml | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config/webpack/development.js b/config/webpack/development.js index 203c6a64e..5b77eb871 100644 --- a/config/webpack/development.js +++ b/config/webpack/development.js @@ -1,8 +1,9 @@ -process.env.NODE_ENV = process.env.NODE_ENV || 'development' +process.env.NODE_ENV = process.env.NODE_ENV || 'development'; -const dotenv = require('dotenv') -dotenv.config({ path: '.env', silent: true }) +const dotenv = require('dotenv'); -const environment = require('./environment') +dotenv.config({ path: '.env', silent: true }); -module.exports = environment.toWebpackConfig() +const environment = require('./environment'); + +module.exports = environment.toWebpackConfig(); diff --git a/config/webpacker.yml b/config/webpacker.yml index 3ca5231de..e1bc412b7 100644 --- a/config/webpacker.yml +++ b/config/webpacker.yml @@ -7,7 +7,7 @@ default: &default public_output_path: packs cache_path: tmp/cache/webpacker check_yarn_integrity: false - webpack_compile_output: false + webpack_compile_output: true # Additional paths webpack should lookup modules # ['app/assets', 'engine/foo/app/assets'] From c40814e1b176a94bf9a79727f7510cad76b257e9 Mon Sep 17 00:00:00 2001 From: Pranav Raj Sreepuram Date: Wed, 21 Aug 2019 21:37:06 +0530 Subject: [PATCH 2/2] Fix compilation errors on production --- babel.config.js | 62 ++++++++++++++++++++++++------------------------- package.json | 8 +++---- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/babel.config.js b/babel.config.js index 80f925ef4..e66c9a424 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,18 +1,20 @@ -module.exports = function(api) { - var validEnv = ['development', 'test', 'production'] - var currentEnv = api.env() - var isDevelopmentEnv = api.env('development') - var isProductionEnv = api.env('production') - var isTestEnv = api.env('test') +/* eslint-disable global-require */ + +module.exports = api => { + const validEnv = ['development', 'test', 'production']; + const currentEnv = api.env(); + const isDevelopmentEnv = api.env('development'); + const isProductionEnv = api.env('production'); + const isTestEnv = api.env('test'); if (!validEnv.includes(currentEnv)) { throw new Error( - 'Please specify a valid `NODE_ENV` or ' + + `${'Please specify a valid `NODE_ENV` or ' + '`BABEL_ENV` environment variables. Valid values are "development", ' + - '"test", and "production". Instead, received: ' + - JSON.stringify(currentEnv) + - '.' - ) + '"test", and "production". Instead, received: '}${JSON.stringify( + currentEnv + )}.` + ); } return { @@ -21,9 +23,9 @@ module.exports = function(api) { require('@babel/preset-env').default, { targets: { - node: 'current' - } - } + node: 'current', + }, + }, ], (isProductionEnv || isDevelopmentEnv) && [ require('@babel/preset-env').default, @@ -32,9 +34,9 @@ module.exports = function(api) { useBuiltIns: 'entry', corejs: 3, modules: false, - exclude: ['transform-typeof-symbol'] - } - ] + exclude: ['transform-typeof-symbol'], + }, + ], ].filter(Boolean), plugins: [ require('babel-plugin-macros'), @@ -44,32 +46,30 @@ module.exports = function(api) { [ require('@babel/plugin-proposal-class-properties').default, { - loose: true - } + loose: true, + }, ], [ require('@babel/plugin-proposal-object-rest-spread').default, { - useBuiltIns: true - } + useBuiltIns: true, + }, ], [ require('@babel/plugin-transform-runtime').default, { helpers: false, regenerator: true, - corejs: false - } + corejs: false, + }, ], [ require('@babel/plugin-transform-regenerator').default, { - async: false - } + async: false, + }, ], - [ - require('babel-plugin-transform-vue-jsx') - ] - ].filter(Boolean) - } -} + [require('babel-plugin-transform-vue-jsx')], + ].filter(Boolean), + }; +}; diff --git a/package.json b/package.json index 55ab68651..bb89a0ec1 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,10 @@ "@rails/webpacker": "^4.0.7", "axios": "^0.19.0", "bourbon": "~4.2.7", + "babel-helper-vue-jsx-merge-props": "^2.0.3", + "babel-plugin-syntax-jsx": "^6.18.0", + "babel-plugin-transform-vue-jsx": "^3.7.0", + "babel-preset-env": "^1.7.0", "chart.js": "~2.5.0", "dotenv": "^8.0.0", "emojione": "~2.2.7", @@ -37,10 +41,6 @@ }, "devDependencies": { "babel-eslint": "^10.0.1", - "babel-helper-vue-jsx-merge-props": "^2.0.3", - "babel-plugin-syntax-jsx": "^6.18.0", - "babel-plugin-transform-vue-jsx": "^3.7.0", - "babel-preset-env": "^1.7.0", "eslint": "^5.13.0", "eslint-config-airbnb": "^17.1.0", "eslint-config-prettier": "^4.0.0",