https://github.com/revan-zhang/placeholder-loader
pipe the raw content to next loader in webpack
https://github.com/revan-zhang/placeholder-loader
loader webpack webpack-loader
Last synced: about 2 months ago
JSON representation
pipe the raw content to next loader in webpack
- Host: GitHub
- URL: https://github.com/revan-zhang/placeholder-loader
- Owner: revan-zhang
- License: gpl-3.0
- Created: 2017-08-17T02:38:30.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-27T15:11:58.000Z (almost 9 years ago)
- Last Synced: 2025-06-11T03:15:14.114Z (about 1 year ago)
- Topics: loader, webpack, webpack-loader
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# placeholder-loader
always return the same source code when pass to the placeholder-loader
why we need this?
bacause in webpack must pass a non-string in loader array, like:
```js
{
test: /\.js$/,
use: [
'babel-loader',
'ts-loader',
]
}
```
but sometime, we want to use different loader in different env, like:
```js
{
test: /\.js$/,
use: [
'babel-loader',
process.env.NODE_ENV === 'production' ? 'awesome-typescript-loader' : 'ts-loader'
]
}
```
the placeholder loader is to solve some config like this:
```js
{
test: /\.js$/,
use: [
'babel-loader',
process.env.NODE_ENV === 'SERVER_RENDERING' ? '' : 'promise-loader'
]
}
```
in the config above, we don't use promise-loader when the SERVER_RENDERING is true,
but webpack doesn't allow empty string, we must write something at there.
so, we can write the path to placeholder-loader, it will pipe the code to next loader.