-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3825371
commit c0d28df
Showing
28 changed files
with
230 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
process.env.NODE_ENV = process.env.NODE_ENV || 'development' | ||
|
||
const environment = require('./environment') | ||
|
||
module.exports = environment.toWebpackConfig() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
process.env.NODE_ENV = process.env.NODE_ENV || 'production' | ||
|
||
const environment = require('./environment') | ||
|
||
module.exports = environment.toWebpackConfig() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
process.env.NODE_ENV = process.env.NODE_ENV || 'development' | ||
|
||
const environment = require('./environment') | ||
|
||
module.exports = environment.toWebpackConfig() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
ENV["NODE_ENV"] ||= "production" | ||
|
||
$stdout.sync = true | ||
|
||
def ensure_log_goes_to_stdout | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* test expect, describe, afterAll, beforeEach */ | ||
|
||
const { resolve } = require('path') | ||
const { chdirTestApp, chdirCwd } = require('../utils/helpers') | ||
|
||
chdirTestApp() | ||
|
||
describe('Development environment', () => { | ||
afterAll(chdirCwd) | ||
|
||
describe('toWebpackConfig', () => { | ||
beforeEach(() => jest.resetModules()) | ||
|
||
test('should use development config and environment', () => { | ||
process.env.RAILS_ENV = 'development' | ||
process.env.NODE_ENV = 'development' | ||
const { environment } = require('../index') | ||
|
||
const config = environment.toWebpackConfig() | ||
expect(config.output.path).toEqual(resolve('public', 'packs')) | ||
expect(config.output.publicPath).toEqual('/packs/') | ||
expect(config).toMatchObject({ | ||
devServer: { | ||
host: 'localhost', | ||
port: 3035 | ||
} | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* test expect, describe, afterAll, beforeEach */ | ||
|
||
const { resolve } = require('path') | ||
const { chdirTestApp, chdirCwd } = require('../utils/helpers') | ||
|
||
chdirTestApp() | ||
|
||
describe('Production environment', () => { | ||
afterAll(chdirCwd) | ||
|
||
describe('toWebpackConfig', () => { | ||
beforeEach(() => jest.resetModules()) | ||
|
||
test('should use production config and environment', () => { | ||
process.env.RAILS_ENV = 'production' | ||
const { environment } = require('../index') | ||
|
||
const config = environment.toWebpackConfig() | ||
expect(config.output.path).toEqual(resolve('public', 'packs')) | ||
expect(config.output.publicPath).toEqual('/packs/') | ||
expect(config).toMatchObject({ | ||
devtool: 'nosources-source-map', | ||
stats: 'normal' | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* test expect, describe, afterAll, beforeEach */ | ||
|
||
const { resolve } = require('path') | ||
const { chdirTestApp, chdirCwd } = require('../utils/helpers') | ||
|
||
chdirTestApp() | ||
|
||
describe('Custom environment', () => { | ||
afterAll(chdirCwd) | ||
|
||
describe('toWebpackConfig', () => { | ||
beforeEach(() => jest.resetModules()) | ||
|
||
test('should use staging config and production environment', () => { | ||
process.env.RAILS_ENV = 'staging' | ||
const { environment } = require('../index') | ||
|
||
const config = environment.toWebpackConfig() | ||
expect(config.output.path).toEqual(resolve('public', 'packs-staging')) | ||
expect(config.output.publicPath).toEqual('/packs-staging/') | ||
expect(config).toMatchObject({ | ||
devtool: 'nosources-source-map', | ||
stats: 'normal' | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* test expect, describe, afterAll, beforeEach */ | ||
|
||
const { resolve } = require('path') | ||
const { chdirTestApp, chdirCwd } = require('../utils/helpers') | ||
|
||
chdirTestApp() | ||
|
||
describe('Test environment', () => { | ||
afterAll(chdirCwd) | ||
|
||
describe('toWebpackConfig', () => { | ||
beforeEach(() => jest.resetModules()) | ||
|
||
test('should use test config and production environment', () => { | ||
process.env.RAILS_ENV = 'test' | ||
const { environment } = require('../index') | ||
|
||
const config = environment.toWebpackConfig() | ||
expect(config.output.path).toEqual(resolve('public', 'packs-test')) | ||
expect(config.output.publicPath).toEqual('/packs-test/') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
const { isBoolean, isEmpty } = require('./utils/helpers') | ||
const { isBoolean } = require('./utils/helpers') | ||
const config = require('./config') | ||
|
||
const fetch = (key) => { | ||
const value = process.env[key] | ||
return isBoolean(value) ? JSON.parse(value) : value | ||
} | ||
|
||
const devServer = () => { | ||
const devServerConfig = config.dev_server | ||
const devServerConfig = config.dev_server | ||
|
||
if (devServerConfig) { | ||
Object.keys(devServerConfig).forEach((key) => { | ||
const envValue = fetch(`WEBPACKER_DEV_SERVER_${key.toUpperCase().replace(/_/g, '')}`) | ||
if (isEmpty(envValue)) return devServerConfig[key] | ||
devServerConfig[key] = envValue | ||
}) | ||
} | ||
|
||
return devServerConfig || {} | ||
if (devServerConfig) { | ||
Object.keys(devServerConfig).forEach((key) => { | ||
const envValue = fetch(`WEBPACKER_DEV_SERVER_${key.toUpperCase().replace(/_/g, '')}`) | ||
if (envValue) devServerConfig[key] = envValue | ||
}) | ||
} | ||
|
||
module.exports = devServer() | ||
module.exports = devServerConfig || {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.