Skip to content

Commit

Permalink
Remove context from file loader
Browse files Browse the repository at this point in the history
Update changelog

Fix test
  • Loading branch information
gauravtiwari committed Jan 25, 2019
1 parent bb1c72b commit 771e3b1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
**Please note that Webpacker 3.1.0 and 3.1.1 have some serious bugs so please consider using either 3.0.2 or 3.2.0**

## [x] - x-x-x

### Fixed

- Remove `context` from file loader in favour of simpler paths

```rb
# before
"_/assets/images/avatar.png": "/packs/_/assets/images/avatar-057862c747f0fdbeae506bdd0516cad1.png"

# after
"media/avatar.png": "/packs/media/avatar-057862c747f0fdbeae506bdd0516cad1.png"
```

### Added

- Namespaces for compiled packs in the public directory

```rb
# before
"runtime~hello_react" => "/packs/runtime~hello_react-da2baf7fd07b0e8b6d17.js"

# after
"runtime~hello_react" => "/packs/js/runtime~hello_react-da2baf7fd07b0e8b6d17.js"
```

## [4.0.0.rc.5] - 2019-01-21

### Updated
Expand Down
4 changes: 2 additions & 2 deletions package/environments/__tests__/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe('Environment', () => {

test('should return output', () => {
const config = environment.toWebpackConfig()
expect(config.output.filename).toEqual('[name]-[chunkhash].js')
expect(config.output.chunkFilename).toEqual('[name]-[chunkhash].chunk.js')
expect(config.output.filename).toEqual('js/[name]-[chunkhash].js')
expect(config.output.chunkFilename).toEqual('js/[name]-[chunkhash].chunk.js')
})

test('should return default loader rules for each file in config/loaders', () => {
Expand Down
10 changes: 5 additions & 5 deletions package/environments/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const getPluginList = () => {
result.append(
'MiniCssExtract',
new MiniCssExtractPlugin({
filename: '[name]-[contenthash:8].css',
chunkFilename: '[name]-[contenthash:8].chunk.css'
filename: 'css/[name]-[contenthash:8].css',
chunkFilename: 'css/[name]-[contenthash:8].chunk.css'
})
)
result.append(
Expand Down Expand Up @@ -83,9 +83,9 @@ const getModulePaths = () => {
const getBaseConfig = () => new ConfigObject({
mode: 'production',
output: {
filename: '[name]-[chunkhash].js',
chunkFilename: '[name]-[chunkhash].chunk.js',
hotUpdateChunkFilename: '[id]-[hash].hot-update.js',
filename: 'js/[name]-[chunkhash].js',
chunkFilename: 'js/[name]-[chunkhash].chunk.js',
hotUpdateChunkFilename: 'js/[id]-[hash].hot-update.js',
path: config.outputPath,
publicPath: config.publicPath
},
Expand Down
6 changes: 2 additions & 4 deletions package/rules/file.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
const { join } = require('path')
const { source_path: sourcePath, static_assets_extensions: fileExtensions } = require('../config')
const { static_assets_extensions: fileExtensions } = require('../config')

module.exports = {
test: new RegExp(`(${fileExtensions.join('|')})$`, 'i'),
use: [
{
loader: 'file-loader',
options: {
name: '[path][name]-[hash].[ext]',
context: join(sourcePath)
name: 'media/[name]-[hash:8].[ext]'
}
}
]
Expand Down

0 comments on commit 771e3b1

Please sign in to comment.