Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
refactor: next
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Nov 25, 2019
1 parent d231710 commit 336e662
Show file tree
Hide file tree
Showing 27 changed files with 2,775 additions and 2,006 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Expand Up @@ -9,5 +9,4 @@ insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
insert_final_newline = true
trim_trailing_whitespace = false
36 changes: 35 additions & 1 deletion README.md
Expand Up @@ -59,6 +59,40 @@ $ webpack --module-bind 'txt=raw-loader'

And run `webpack` via your preferred method.

## Options

### `esModule`

Type: `Boolean`
Default: `true`

By default, `raw-loader` generates JS modules that use the ES modules syntax.
There are some cases in which using ES modules is beneficial, like in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/).

You can enable a CommonJS module syntax using:

**webpack.config.js**

```js
module.exports = {
module: {
rules: [
{
test: /\.txt$/i,
use: [
{
loader: 'raw-loader',
options: {
esModule: false,
},
},
],
},
],
},
};
```

## Examples

### Inline
Expand All @@ -70,7 +104,7 @@ import txt from 'raw-loader!./file.txt';
Beware, if you already define loader(s) for extension(s) in `webpack.config.js` you should use:

```js
import css from '!!raw-loader!./file.css'; // Adding `!!` to a request will disable all loaders specified in the configuration
import css from '!!raw-loader!./file.txt'; // Adding `!!` to a request will disable all loaders specified in the configuration
```

## Contributing
Expand Down
76 changes: 42 additions & 34 deletions azure-pipelines.yml
Expand Up @@ -2,10 +2,13 @@ trigger:
- master
- next

variables:
npm_config_cache: $(Pipeline.Workspace)/.npm

jobs:
- job: Lint
pool:
vmImage: ubuntu-16.04
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
Expand All @@ -20,10 +23,12 @@ jobs:
node -v
npm -v
displayName: 'Print versions'
- task: Npm@1
- task: CacheBeta@1
inputs:
command: custom
customCommand: ci
key: npm | $(Agent.OS) | package-lock.json
path: $(npm_config_cache)
displayName: 'Cache npm'
- script: npm ci
displayName: 'Install dependencies'
- script: npm run lint
displayName: 'Run lint'
Expand All @@ -34,23 +39,22 @@ jobs:

- job: Linux
pool:
vmImage: ubuntu-16.04
vmImage: ubuntu-latest
strategy:
maxParallel: 4
matrix:
node-13:
node_version: ^13.0.0
webpack_version: latest
node-12:
node_version: ^12.0.0
webpack_version: latest
node-10:
node_version: ^10.13.0
webpack_version: latest
node-8:
node_version: ^8.9.0
webpack_version: latest
node-8-canary:
node_version: ^8.9.0
node-10-canary:
node_version: ^10.13.0
webpack_version: next
continue_on_error: true
steps:
- task: NodeTool@0
inputs:
Expand All @@ -65,10 +69,12 @@ jobs:
node -v
npm -v
displayName: 'Print versions'
- task: Npm@1
- task: CacheBeta@1
inputs:
command: custom
customCommand: ci
key: npm | $(Agent.OS) | package-lock.json
path: $(npm_config_cache)
displayName: 'Cache npm'
- script: npm ci
displayName: 'Install dependencies'
- script: npm i webpack@$(webpack_version)
displayName: 'Install "webpack@$(webpack_version)"'
Expand All @@ -86,23 +92,22 @@ jobs:

- job: macOS
pool:
vmImage: macOS-10.14
vmImage: macOS-latest
strategy:
maxParallel: 4
matrix:
node-13:
node_version: ^13.0.0
webpack_version: latest
node-12:
node_version: ^12.0.0
webpack_version: latest
node-10:
node_version: ^10.13.0
webpack_version: latest
node-8:
node_version: ^8.9.0
webpack_version: latest
node-8-canary:
node_version: ^8.9.0
node-10-canary:
node_version: ^10.13.0
webpack_version: next
continue_on_error: true
steps:
- task: NodeTool@0
inputs:
Expand All @@ -117,10 +122,12 @@ jobs:
node -v
npm -v
displayName: 'Print versions'
- task: Npm@1
- task: CacheBeta@1
inputs:
command: custom
customCommand: ci
key: npm | $(Agent.OS) | package-lock.json
path: $(npm_config_cache)
displayName: 'Cache npm'
- script: npm ci
displayName: 'Install dependencies'
- script: npm i webpack@$(webpack_version)
displayName: 'Install "webpack@$(webpack_version)"'
Expand All @@ -138,23 +145,22 @@ jobs:

- job: Windows
pool:
vmImage: windows-2019
vmImage: windows-latest
strategy:
maxParallel: 4
matrix:
node-13:
node_version: ^13.0.0
webpack_version: latest
node-12:
node_version: ^12.0.0
webpack_version: latest
node-10:
node_version: ^10.13.0
webpack_version: latest
node-8:
node_version: ^8.9.0
webpack_version: latest
node-8-canary:
node_version: ^8.9.0
node-10-canary:
node_version: ^10.13.0
webpack_version: next
continue_on_error: true
steps:
- script: 'git config --global core.autocrlf input'
displayName: 'Config git core.autocrlf'
Expand All @@ -172,10 +178,12 @@ jobs:
node -v
npm -v
displayName: 'Print versions'
- task: Npm@1
- task: CacheBeta@1
inputs:
command: custom
customCommand: ci
key: npm | $(Agent.OS) | package-lock.json
path: $(npm_config_cache)
displayName: 'Cache npm'
- script: npm ci
displayName: 'Install dependencies'
- script: npm i webpack@$(webpack_version)
displayName: 'Install "webpack@$(webpack_version)"'
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Expand Up @@ -10,7 +10,7 @@ module.exports = (api) => {
'@babel/preset-env',
{
targets: {
node: '8.9.0',
node: '10.13.0',
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion lint-staged.config.js
@@ -1,4 +1,4 @@
module.exports = {
'*.js': ['prettier --write', 'eslint --fix', 'git add'],
'*.{json,md,yml,css}': ['prettier --write', 'git add'],
'*.{json,md,yml,css,ts}': ['prettier --write', 'git add'],
};

0 comments on commit 336e662

Please sign in to comment.