-
-
Notifications
You must be signed in to change notification settings - Fork 426
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
Showing
9 changed files
with
1,320 additions
and
275 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
lib/ | ||
__fixtures_build__/ | ||
src/__fixtures__/dist/ | ||
coverage/ |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,3 @@ | ||
import icon from './icon.svg' | ||
|
||
global.exported_icon = icon |
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,12 @@ | ||
import loaderUtils from 'loader-utils' | ||
import convert from './' | ||
|
||
function svgrLoader(source) { | ||
const callback = this.async() | ||
const options = loaderUtils.getOptions(this) || {} | ||
convert(source, options) | ||
.then(result => callback(null, result)) | ||
.catch(err => callback(err)) | ||
} | ||
|
||
export default svgrLoader |
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,59 @@ | ||
import path from 'path' | ||
import webpack from 'webpack' | ||
|
||
describe('webpack loader', () => { | ||
it('should convert file', () => | ||
new Promise((resolve, reject) => { | ||
webpack( | ||
{ | ||
entry: path.resolve(__dirname, '__fixtures__/main.js'), | ||
output: { | ||
path: path.resolve(__dirname, '__fixtures__/dist'), | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.svg$/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: { | ||
presets: [ | ||
[ | ||
'env', | ||
{ | ||
targets: { | ||
node: '6', | ||
}, | ||
}, | ||
], | ||
'react', | ||
], | ||
plugins: [ | ||
'transform-class-properties', | ||
'transform-object-rest-spread', | ||
], | ||
}, | ||
}, | ||
{ | ||
loader: path.resolve(__dirname, 'webpack.js'), | ||
options: { | ||
expandProps: false, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
(err, stats) => { | ||
if (err || stats.hasErrors()) reject(err) | ||
/* eslint-disable global-require, import/no-dynamic-require */ | ||
require(path.resolve(__dirname, '__fixtures__/dist/main.js')) | ||
/* eslint-enable global-require, import/no-dynamic-require */ | ||
expect(global.exported_icon.name).toBe('SvgComponent') | ||
resolve() | ||
}, | ||
) | ||
})) | ||
}) |
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 @@ | ||
module.exports = require('./lib/webpack') |
Oops, something went wrong.