-
Notifications
You must be signed in to change notification settings - Fork 0
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
5 changed files
with
116 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
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,2 +1,55 @@ | ||
# nuxt-resolve-url-loader | ||
Nuxt module for adding resolve-url-loader to webpack config. | ||
|
||
[![npm downloads][npm-downloads-src]][npm-downloads-href] | ||
[![License][license-src]][license-href] | ||
|
||
> Easy add 'resolve-url-loader' to Nuxt.js webpack config | ||
## Requirements | ||
|
||
You need to ensure that you have `resolve-url-loader` installed: | ||
|
||
```bash | ||
npm install --save-dev resolve-url-loader | ||
``` | ||
|
||
## Setup | ||
|
||
1. Add `nuxt-resolve-url-loader` dependency to your project | ||
|
||
```bash | ||
npm install --save-dev nuxt-resolve-url-loader | ||
``` | ||
|
||
2. Add `nuxt-resolve-url-loader` to the `buildModules` section of `nuxt.config.js` | ||
|
||
```js | ||
export default { | ||
buildModules: [ | ||
// Simple usage | ||
'nuxt-resolve-url-loader', | ||
|
||
// With options | ||
['nuxt-resolve-url-loader', { /* options for resolve-url-loader */ }] | ||
] | ||
} | ||
``` | ||
|
||
:warning: If you are using Nuxt **< v2.9** you have to install the module as a `dependency` (No `--dev` or `--save-dev` flags) and use `modules` section in `nuxt.config.js` instead of `buildModules`. | ||
|
||
## Options | ||
|
||
See [resolve-url-loader options](https://www.npmjs.com/package/resolve-url-loader#options) for the complete list of options available. These options are passed through to the `resolve-url-loader` directly. | ||
|
||
## License | ||
|
||
[MIT License](./LICENSE) | ||
|
||
Copyright (c) Igor Pylypenko | ||
|
||
<!-- Badges --> | ||
[npm-downloads-src]: https://img.shields.io/npm/dt/nuxt-resolve-url-loader.svg | ||
[npm-downloads-href]: https://npmjs.com/package/nuxt-resolve-url-loader | ||
|
||
[license-src]: https://img.shields.io/npm/l/nuxt-resolve-url-loader.svg | ||
[license-href]: https://npmjs.com/package/nuxt-resolve-url-loader |
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 @@ | ||
const traverse = require('traverse'); | ||
|
||
module.exports = function (options) { | ||
this.extendBuild(function setup(config) { | ||
traverse(config).forEach(function (some) { | ||
if (this.key !== 'loader' || some !== 'sass-loader') return; | ||
|
||
let loaderConfig = this.parent.node; | ||
loaderConfig = { ...loaderConfig, options: { ...loaderConfig.options, sourceMap: true } }; | ||
|
||
this.parent.update(loaderConfig); | ||
|
||
const array = [...this.parent.parent.node]; | ||
|
||
array.splice(this.parent.path.pop(), 0, { | ||
loader: 'resolve-url-loader', | ||
options | ||
}); | ||
|
||
this.parent.parent.update(array); | ||
}); | ||
}); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,25 @@ | ||
{ | ||
"name": "nuxt-resolve-url-loader", | ||
"version": "1.0.0", | ||
"description": "Nuxt module for adding resolve-url-loader to webpack config.", | ||
"main": "nuxt-resolve-url-loader.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Dryymoon/nuxt-resolve-url-loader.git" | ||
}, | ||
"author": "Igor Pylypenko", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Dryymoon/nuxt-resolve-url-loader/issues" | ||
}, | ||
"homepage": "https://github.com/Dryymoon/nuxt-resolve-url-loader#readme", | ||
"dependencies": { | ||
"traverse": "^0.6.6" | ||
}, | ||
"peerDependencies": { | ||
"resolve-url-loader": "^3.1.2" | ||
} | ||
} |