This repository has been archived by the owner on Jul 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Reorder slate-tools.schema.js items to alphabetical - Rename some settings in slate-tools.schema.js for better scoping
- Loading branch information
t-kelly
committed
Sep 10, 2018
1 parent
5deb560
commit 81ed64f
Showing
10 changed files
with
139 additions
and
76 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
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
51 changes: 51 additions & 0 deletions
51
packages/slate-tools/tools/webpack/config/parts/__tests__/babel.test.js
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,51 @@ | ||
const mock = require('mock-fs'); | ||
|
||
beforeEach(() => { | ||
global.slateUserConfig = {}; | ||
jest.resetModules(); | ||
}); | ||
|
||
afterEach(mock.restore); | ||
|
||
describe('returns an empty object', () => { | ||
test(`if 'webpack.babel.enable' config is set to false`, () => { | ||
global.slateUserConfig['webpack.babel.enable'] = false; | ||
|
||
const babelLoader = require('../babel'); | ||
const results = babelLoader(); | ||
|
||
expect(typeof results).toBe('object'); | ||
expect(Object.keys(results).length).toBe(0); | ||
}); | ||
test(`if file at 'webpack.babel.configPath' config does not exist`, () => { | ||
const babelLoader = require('../babel'); | ||
|
||
mock(); | ||
|
||
const results = babelLoader(); | ||
|
||
expect(typeof results).toBe('object'); | ||
expect(Object.keys(results).length).toBe(0); | ||
}); | ||
}); | ||
|
||
describe('returns a webpack config object containing babel-loader', () => { | ||
test(`if 'webpack.babel.enable' config is true and file at 'webpack.babel.configPath' exists`, () => { | ||
const babelConfigPath = 'some/path'; | ||
|
||
global.slateUserConfig['webpack.babel.configPath'] = babelConfigPath; | ||
|
||
const babelLoader = require('../babel'); | ||
|
||
mock({[babelConfigPath]: '{}'}); | ||
|
||
const results = babelLoader(); | ||
|
||
expect(typeof results).toBe('object'); | ||
expect(results.module).toBeDefined(); | ||
expect(results.module.rules).toBeDefined(); | ||
expect(Array.isArray(results.module.rules)).toBeTruthy(); | ||
expect(typeof results.module.rules[0]).toBe('object'); | ||
expect(results.module.rules[0].options.extends).toBe(babelConfigPath); | ||
}); | ||
}); |
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 @@ | ||
const fs = require('fs'); | ||
const SlateConfig = require('@shopify/slate-config'); | ||
|
||
const commonExcludes = require('../../common-excludes'); | ||
const config = new SlateConfig(require('../../../../slate-tools.schema')); | ||
|
||
module.exports = () => { | ||
if ( | ||
!fs.existsSync(config.get('webpack.babel.configPath')) || | ||
!config.get('webpack.babel.enable') | ||
) { | ||
return {}; | ||
} | ||
|
||
return { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: commonExcludes(), | ||
loader: 'babel-loader', | ||
options: { | ||
babelrc: false, | ||
extends: config.get('webpack.babel.configPath'), | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
}; |
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
26 changes: 0 additions & 26 deletions
26
packages/slate-tools/tools/webpack/loaders/babel-loader.js
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