nanoc-webpack.rb is a
nanoc
filter that adds
webpack
support to nanoc.
The filter connects nanoc to the JavaScript, TypeScript,
and nodejs ecosystems.
Defaults
The following example forwards the entry point /js/main/App.tsx
to webpack.
The result is then written to /js/main/app.js
:
# Rules
require "nanoc-webpack"
compile "/js/main/App.tsx" do
filter(:webpack)
write("/js/main/app.js")
end
Option: depend_on
When a file or directory tracked by the depend_on
option
is observed to have changed, nanoc will initiate a recompilation
of the entry point:
# Rules
require "nanoc-webpack"
compile "/js/main/App.tsx" do
filter(:webpack, depend_on: ["/js/lib", "/js/components", "/js/hooks"])
write("/js/main/app.js")
end
Option: reject
The depend_on
option can be combined with the reject
option to exclude
certain files or directories from being tracked. For example, maybe you want
to track /js/lib/
but not /js/lib/foo/
:
# Rules
require "nanoc-webpack"
compile "/js/main/App.tsx" do
filter :webpack,
depend_on: ["/js/lib", "/js/components", "/js/hooks"],
reject: proc { |path| path.start_with?("/js/lib/foo/") }
write("/js/main/app.js")
end
Option: argv
The argv
option forwards command line arguments directly
to the webpack executable.
Nanoc::Webpack.default_argv
returns the default command line arguments forwarded to webpack:
# Rules
require "nanoc-webpack"
compile "/js/main/App.tsx" do
filter(:webpack, argv: ["--config", "webpack.production.js"])
write("/js/main/app.js")
end
nanoc-webpack.rb can be installed via rubygems.org:
gem install nanoc-webpack.rb
- 0x1eef/terry.reflectslight.io
A simple nanoc website that uses nanoc-webpack.rb