Skip to content

Commit

Permalink
Merge pull request #25 from smooth-code/webpack-usage
Browse files Browse the repository at this point in the history
feat: simplify webpack usage
  • Loading branch information
gregberge committed Dec 4, 2017
2 parents 039f2cb + 7ac643e commit 98d499e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
!/lib/*.js
!/bin/svgr
*.test.js
!/webpack.js
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ module.exports = {
rules: [
{
test: /\.svg$/,
use: ['babel-loader', 'svgr/lib/webpack'],
use: ['babel-loader', 'svgr/webpack'],
},
],
},
Expand All @@ -220,7 +220,7 @@ module.exports = {
use: [
'babel-loader',
{
loader: 'svgr/lib/webpack',
loader: 'svgr/webpack',
options: {
svgo: false,
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@
},
"scripts": {
"build": "rm -rf lib/ && NODE_ENV=production babel src -d lib",
"ci": "yarn lint && yarn test",
"ci": "yarn lint && yarn build && yarn test",
"format": "prettier --write \"src/**/*.js\"",
"lint": "eslint .",
"release": "yarn build && standard-version && conventional-github-releaser",
"clear": "rm -rf __fixtures_build__ lib",
"test": "npm run clear && jest --runInBand --coverage && codecov",
"test": "jest --runInBand --coverage && codecov",
"prepublishOnly": "yarn run build"
}
}
10 changes: 9 additions & 1 deletion src/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ function svgrLoader(source) {
.catch(err => callback(err))
}

export default svgrLoader
function svgrLoaderWithWarning(source) {
console.warn(
'Using "svgr/lib/webpack" is deprecated and will be removed in v2. Please use "svgr/webpack" instead.',
)
return svgrLoader.call(this, source)
}

export { svgrLoader }
export default svgrLoaderWithWarning
2 changes: 1 addition & 1 deletion src/webpack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('webpack loader', () => {
},
},
{
loader: path.resolve(__dirname, 'webpack.js'),
loader: path.resolve(__dirname, '../webpack.js'),
options: {
expandProps: false,
},
Expand Down
2 changes: 1 addition & 1 deletion webpack.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/* eslint-disable import/no-unresolved */
module.exports = require('./lib/webpack')
module.exports = require('./lib/webpack').svgrLoader

0 comments on commit 98d499e

Please sign in to comment.