@rails/webpacker
Advanced tools
Changelog
[3.3.0] - 2018-03-03
relative_url_root
to webpacker config #1236bundle exec rails webpacker:binstubs
append
or prepend
// config/webpack/environment.js
const { environment } = require('@rails/webpacker')
environment.loaders.append('json', {
test: /\.json$/,
use: 'json-loader'
})
Changelog
[3.2.2] - 2018-02-11
bundle exec rails webpacker:install:stimulus
And, bunch of bug fixes See changes
Changelog
[3.2.1] - 2018-01-21
Disable dev server running? check if no dev server config is present in that environment #1179
Fix checking 'webpack' binstub on Windows #1123
silence yarn output if checking is successful #1131
Update uglifyJs plugin to support ES6 #1194
Add typescript installer #1145
Update default extensions and move to installer #1181
Revert file loader #1196
Changelog
[3.2.0] - 2017-12-16
bundle update webpacker
yarn upgrade @rails/webpacker
If you are using react, vue, angular, elm, erb or coffeescript inside your
packs/
please re-run the integration installers as described in the README.
bundle exec rails webpacker:install:react
bundle exec rails webpacker:install:vue
bundle exec rails webpacker:install:angular
bundle exec rails webpacker:install:elm
bundle exec rails webpacker:install:erb
bundle exec rails webpacker:install:coffee
Or simply copy required loaders used in your app from
https://github.com/rails/webpacker/tree/master/lib/install/loaders
into your config/webpack/loaders/
directory and add it to webpack build from config/webpack/environment.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')
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
:
plugins:
postcss-import: {}
postcss-cssnext: {}
Upgrade gems and webpack dependencies
postcss-import
in place of postcss-smart-import
postcss-smart-import
, coffee-loader
, url-loader
, rails-erb-loader
as dependencies
publicPath
from file loader #1107
ConfigList
#1098New asset_pack_url
helper #1102
New installers for coffee and erb
bundle exec rails webpacker:install:erb
bundle exec rails webpacker:install:coffee
Changelog
[3.1.1] - 2017-12-11
Changelog
[3.1.0] - 2017-12-11
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'
}
})
const jsonLoader = {
test: /\.json$/,
exclude: /node_modules/,
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' })
// Update a plugin
const manifestPlugin = environment.plugins.get('Manifest')
manifestPlugin.opts.writeToFileEmit = false
// Update coffee loader to use coffeescript 2
const babelLoader = environment.loaders.get('babel')
environment.loaders.insert(
'coffee',
{
test: /\.coffee(\.erb)?$/,
use: babelLoader.use.concat(['coffee-loader'])
},
{ before: 'json' }
)
resolve.modules
paths like loaders and pluginsenvironment.resolvedModules.append('vendor', 'vendor')
Enable sourcemaps in style
and css
loader
Separate css
and sass
loader for easier configuration. style
loader is now
css
loader, which resolves .css
files and sass
loader resolves .scss
and .sass
files.
// Enable css modules with sass 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]'
})
quiet: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: /node_modules/
pretty
option to disable/enable color and progress output when running dev serverdev_server:
pretty: false
Enforce deterministic loader order in desc order, starts processing from top to bottom
Enforce the entire path of all required modules match the exact case of the actual path on disk using case sensitive paths plugin.
Add url loader to process and embed smaller static files
WEBPACKER_PRECOMPILE=no|false|n|f
WEBPACKER_PRECOMPILE=false bundle exec rails assets:precompile
Use WEBPACKER_ASSET_HOST
instead of ASSET_HOST
for CDN
Alias webpacker:compile
task to assets:precompile
if is not defined so it works
without sprockets
Changelog
[3.0.2] - 2017-10-04
# Change to 1s
Webpacker.dev_server.connect_timeout = 1
Restrict the source maps generated in production #770
Binstubs #833
Allow dev server settings to be overridden by env variables #843
A new lookup
method to manifest to perform lookup without raise and return nil
Webpacker.manifest.lookup('foo.js')
# => nil
Webpacker.manifest.lookup!('foo.js')
# => raises Webpacker::Manifest::MissingEntryError
DevServer.running?
and return false #878Inline CLI args for dev server binstub, use env variables instead
Coffeescript as core dependency. You have to manually add coffeescript now, if you are using it in your app.
yarn add coffeescript@1.12.7
# OR coffeescript 2.0
yarn add coffeescript