Skip to content

Commit

Permalink
4.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravtiwari committed Nov 12, 2019
1 parent 93152cf commit d905149
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 57 deletions.
114 changes: 60 additions & 54 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
**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**

**Please note that Webpacker 4.1.0 has an installer bug. Please use 4.2.0 or above**

## [[4.2.0]](https://github.com/rails/webpacker/compare/v4.1.0...v4.2.0) - 2019-11-12

- Fixed installer bug [#2366](https://github.com/rails/webpacker/pull/2366)

## [[4.1.0]](https://github.com/rails/webpacker/compare/v4.0.7...v4.1.0) - 2019-11-12

- Added favicon_pack_tag to generate favicon links [#2281](https://github.com/rails/webpacker/pull/2281)
Expand Down Expand Up @@ -43,14 +49,14 @@ Please see the diff
In each of your `/packs/*.js` files, change this:

```js
import '@babel/polyfill'
import "@babel/polyfill";
```

to this:

```js
import 'core-js/stable'
import 'regenerator-runtime/runtime'
import "core-js/stable";
import "regenerator-runtime/runtime";
```

Don't forget to install those dependencies directly!
Expand Down Expand Up @@ -87,10 +93,10 @@ Source maps can be disabled in any environment configuration, e.g:
```js
// config/webpack/production.js

const environment = require('./environment')
environment.config.merge({ devtool: 'none' })
const environment = require("./environment");
environment.config.merge({ devtool: "none" });

module.exports = environment.toWebpackConfig()
module.exports = environment.toWebpackConfig();
```

- Reintroduced `context` to the file loader. Reverting the simpler paths change
Expand Down Expand Up @@ -141,12 +147,12 @@ To get old behaviour:
```js
// config/webpack/environment.js

const { environment, config } = require('@rails/webpacker')
const { join } = require('path')
const { environment, config } = require("@rails/webpacker");
const { join } = require("path");

const fileLoader = environment.loaders.get('file')
fileLoader.use[0].options.name = '[path][name]-[hash].[ext]'
fileLoader.use[0].options.context = join(config.source_path) // optional if you don't want to expose full paths
const fileLoader = environment.loaders.get("file");
fileLoader.use[0].options.name = "[path][name]-[hash].[ext]";
fileLoader.use[0].options.context = join(config.source_path); // optional if you don't want to expose full paths
```

### Added
Expand Down Expand Up @@ -240,7 +246,7 @@ helper otherwise you will get duplicated chunks on the page.
depending on how you want to process packs [#1823](https://github.com/rails/webpacker/pull/1823)

```js
environment.loaders.prepend()
environment.loaders.prepend();
```

- Separate CSS extraction from build environment [#1625](https://github.com/rails/webpacker/pull/1625)
Expand Down Expand Up @@ -275,13 +281,13 @@ static_assets_extensions:
- Add split chunks api (undocumented)

```js
const { environment } = require('@rails/webpacker')
const { environment } = require("@rails/webpacker");
// Enable with default config
environment.splitChunks()
environment.splitChunks();
// Configure via a callback
environment.splitChunks(config =>
Object.assign({}, config, { optimization: { splitChunks: false } })
)
);
```

- Allow changing static file extensions using webpacker.yml (undocumented)
Expand Down Expand Up @@ -412,12 +418,12 @@ bundle exec rails webpacker:binstubs

```js
// config/webpack/environment.js
const { environment } = require('@rails/webpacker')
const { environment } = require("@rails/webpacker");
environment.loaders.append('json', {
environment.loaders.append("json", {
test: /\.json$/,
use: 'json-loader'
})
use: "json-loader"
});
```

### Fixed
Expand Down Expand Up @@ -484,17 +490,17 @@ into your `config/webpack/loaders/`
directory and add it to webpack build from `config/webpack/environment.js`

```js
const erb = require('./loaders/erb')
const elm = require('./loaders/elm')
const typescript = require('./loaders/typescript')
const vue = require('./loaders/vue')
const coffee = require('./loaders/coffee')
const erb = require("./loaders/erb");
const elm = require("./loaders/elm");
const typescript = require("./loaders/typescript");
const vue = require("./loaders/vue");
const coffee = require("./loaders/coffee");
environment.loaders.append('coffee', coffee)
environment.loaders.append('vue', vue)
environment.loaders.append('typescript', typescript)
environment.loaders.append('elm', elm)
environment.loaders.append('erb', erb)
environment.loaders.append("coffee", coffee);
environment.loaders.append("vue", vue);
environment.loaders.append("typescript", typescript);
environment.loaders.append("elm", elm);
environment.loaders.append("erb", erb);
```

In `.postcssrc.yml` you need to change the plugin name from `postcss-smart-import` to `postcss-import`:
Expand Down Expand Up @@ -547,15 +553,15 @@ bundle exec rails webpacker:install:coffee
- Expose base config from environment

```js
environment.config.set('resolve.extensions', ['.foo', '.bar'])
environment.config.set('output.filename', '[name].js')
environment.config.delete('output.chunkFilename')
environment.config.get('resolve')
environment.config.set("resolve.extensions", [".foo", ".bar"]);
environment.config.set("output.filename", "[name].js");
environment.config.delete("output.chunkFilename");
environment.config.get("resolve");
environment.config.merge({
output: {
filename: '[name].js'
filename: "[name].js"
}
})
});
```

- Expose new API's for loaders and plugins to insert at position
Expand All @@ -564,34 +570,34 @@ environment.config.merge({
const jsonLoader = {
test: /\.json$/,
exclude: /node_modules/,
loader: 'json-loader'
}
loader: "json-loader"
};
environment.loaders.append('json', jsonLoader)
environment.loaders.prepend('json', jsonLoader)
environment.loaders.insert('json', jsonLoader, { after: 'style' })
environment.loaders.insert('json', jsonLoader, { before: 'babel' })
environment.loaders.append("json", jsonLoader);
environment.loaders.prepend("json", jsonLoader);
environment.loaders.insert("json", jsonLoader, { after: "style" });
environment.loaders.insert("json", jsonLoader, { before: "babel" });
// Update a plugin
const manifestPlugin = environment.plugins.get('Manifest')
manifestPlugin.opts.writeToFileEmit = false
const manifestPlugin = environment.plugins.get("Manifest");
manifestPlugin.opts.writeToFileEmit = false;
// Update coffee loader to use coffeescript 2
const babelLoader = environment.loaders.get('babel')
const babelLoader = environment.loaders.get("babel");
environment.loaders.insert(
'coffee',
"coffee",
{
test: /\.coffee(\.erb)?$/,
use: babelLoader.use.concat(['coffee-loader'])
use: babelLoader.use.concat(["coffee-loader"])
},
{ before: 'json' }
)
{ before: "json" }
);
```

- Expose `resolve.modules` paths like loaders and plugins

```js
environment.resolvedModules.append('vendor', 'vendor')
environment.resolvedModules.append("vendor", "vendor");
```

- Enable sourcemaps in `style` and `css` loader
Expand All @@ -602,21 +608,21 @@ environment.resolvedModules.append('vendor', 'vendor')

```js
// Enable css modules with sass loader
const sassLoader = environment.loaders.get('sass')
const cssLoader = sassLoader.use.find(loader => loader.loader === 'css-loader')
const sassLoader = environment.loaders.get("sass");
const cssLoader = sassLoader.use.find(loader => loader.loader === "css-loader");
cssLoader.options = Object.assign({}, cssLoader.options, {
modules: true,
localIdentName: '[path][name]__[local]--[hash:base64:5]'
})
localIdentName: "[path][name]__[local]--[hash:base64:5]"
});
```

- Expose rest of configurable dev server options from webpacker.yml

```yml
quiet: false
headers:
'Access-Control-Allow-Origin': '*'
"Access-Control-Allow-Origin": "*"
watch_options:
ignored: /node_modules/
```
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
webpacker (4.1.0)
webpacker (4.2.0)
activesupport (>= 4.2)
rack-proxy (>= 0.6.1)
railties (>= 4.2)
Expand Down
2 changes: 1 addition & 1 deletion lib/webpacker/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Webpacker
# Change the version in package.json too, please!
VERSION = "4.1.0".freeze
VERSION = "4.2.0".freeze
end
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rails/webpacker",
"version": "4.1.0",
"version": "4.2.0",
"description": "Use webpack to manage app-like JavaScript modules in Rails",
"main": "package/index.js",
"files": [
Expand Down

0 comments on commit d905149

Please sign in to comment.