bridgetown-core 0.19.3 → 0.21.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bridgetown-core.gemspec +1 -2
- data/lib/bridgetown-core.rb +37 -29
- data/lib/bridgetown-core/cleaner.rb +9 -3
- data/lib/bridgetown-core/collection.rb +177 -78
- data/lib/bridgetown-core/commands/base.rb +9 -0
- data/lib/bridgetown-core/commands/build.rb +0 -11
- data/lib/bridgetown-core/commands/concerns/git_helpers.rb +20 -0
- data/lib/bridgetown-core/commands/configure.rb +8 -3
- data/lib/bridgetown-core/commands/console.rb +4 -0
- data/lib/bridgetown-core/commands/doctor.rb +1 -19
- data/lib/bridgetown-core/commands/new.rb +6 -6
- data/lib/bridgetown-core/commands/plugins.rb +14 -13
- data/lib/bridgetown-core/commands/serve.rb +0 -14
- data/lib/bridgetown-core/commands/webpack.rb +75 -0
- data/lib/bridgetown-core/commands/webpack/enable-postcss.rb +12 -0
- data/lib/bridgetown-core/commands/webpack/setup.rb +4 -0
- data/lib/bridgetown-core/commands/webpack/update.rb +3 -0
- data/lib/bridgetown-core/commands/webpack/webpack.config.js +18 -0
- data/lib/{site_template/webpack.config.js.erb → bridgetown-core/commands/webpack/webpack.defaults.js.erb} +32 -16
- data/lib/bridgetown-core/component.rb +183 -0
- data/lib/bridgetown-core/concerns/data_accessible.rb +1 -0
- data/lib/bridgetown-core/concerns/front_matter_importer.rb +52 -0
- data/lib/bridgetown-core/concerns/layout_placeable.rb +1 -1
- data/lib/bridgetown-core/concerns/site/configurable.rb +10 -10
- data/lib/bridgetown-core/concerns/site/content.rb +56 -15
- data/lib/bridgetown-core/concerns/site/localizable.rb +3 -5
- data/lib/bridgetown-core/concerns/site/processable.rb +6 -4
- data/lib/bridgetown-core/concerns/site/renderable.rb +26 -0
- data/lib/bridgetown-core/concerns/site/writable.rb +12 -2
- data/lib/bridgetown-core/concerns/validatable.rb +2 -5
- data/lib/bridgetown-core/configuration.rb +61 -33
- data/lib/bridgetown-core/configurations/bt-postcss.rb +6 -6
- data/lib/bridgetown-core/configurations/netlify.rb +1 -0
- data/lib/bridgetown-core/configurations/tailwindcss.rb +6 -6
- data/lib/bridgetown-core/converter.rb +23 -0
- data/lib/bridgetown-core/converters/erb_templates.rb +51 -35
- data/lib/bridgetown-core/converters/identity.rb +0 -9
- data/lib/bridgetown-core/converters/liquid_templates.rb +1 -1
- data/lib/bridgetown-core/converters/markdown.rb +14 -4
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +5 -38
- data/lib/bridgetown-core/converters/ruby_templates.rb +17 -0
- data/lib/bridgetown-core/converters/smartypants.rb +3 -1
- data/lib/bridgetown-core/core_ext/psych.rb +19 -0
- data/lib/bridgetown-core/current.rb +10 -0
- data/lib/bridgetown-core/document.rb +9 -16
- data/lib/bridgetown-core/drops/collection_drop.rb +1 -1
- data/lib/bridgetown-core/drops/page_drop.rb +4 -0
- data/lib/bridgetown-core/drops/relations_drop.rb +23 -0
- data/lib/bridgetown-core/drops/resource_drop.rb +83 -0
- data/lib/bridgetown-core/drops/site_drop.rb +33 -8
- data/lib/bridgetown-core/drops/unified_payload_drop.rb +5 -0
- data/lib/bridgetown-core/entry_filter.rb +17 -28
- data/lib/bridgetown-core/errors.rb +0 -2
- data/lib/bridgetown-core/filters.rb +3 -26
- data/lib/bridgetown-core/filters/from_liquid.rb +23 -0
- data/lib/bridgetown-core/filters/url_filters.rb +12 -0
- data/lib/bridgetown-core/frontmatter_defaults.rb +1 -1
- data/lib/bridgetown-core/generators/prototype_generator.rb +59 -20
- data/lib/bridgetown-core/helpers.rb +48 -9
- data/lib/bridgetown-core/layout.rb +53 -21
- data/lib/bridgetown-core/liquid_renderer/file.rb +1 -0
- data/lib/bridgetown-core/liquid_renderer/table.rb +1 -0
- data/lib/bridgetown-core/model/base.rb +138 -0
- data/lib/bridgetown-core/model/builder_origin.rb +40 -0
- data/lib/bridgetown-core/model/origin.rb +38 -0
- data/lib/bridgetown-core/model/repo_origin.rb +126 -0
- data/lib/bridgetown-core/page.rb +11 -2
- data/lib/bridgetown-core/plugin_manager.rb +1 -3
- data/lib/bridgetown-core/publisher.rb +8 -2
- data/lib/bridgetown-core/reader.rb +37 -22
- data/lib/bridgetown-core/readers/data_reader.rb +5 -5
- data/lib/bridgetown-core/readers/defaults_reader.rb +1 -1
- data/lib/bridgetown-core/readers/layout_reader.rb +1 -1
- data/lib/bridgetown-core/readers/page_reader.rb +1 -0
- data/lib/bridgetown-core/readers/post_reader.rb +5 -4
- data/lib/bridgetown-core/regenerator.rb +9 -2
- data/lib/bridgetown-core/related_posts.rb +9 -6
- data/lib/bridgetown-core/renderer.rb +6 -13
- data/lib/bridgetown-core/resource/base.rb +329 -0
- data/lib/bridgetown-core/resource/destination.rb +49 -0
- data/lib/bridgetown-core/resource/permalink_processor.rb +179 -0
- data/lib/bridgetown-core/resource/relations.rb +132 -0
- data/lib/bridgetown-core/resource/taxonomy_term.rb +34 -0
- data/lib/bridgetown-core/resource/taxonomy_type.rb +56 -0
- data/lib/bridgetown-core/resource/transformer.rb +177 -0
- data/lib/bridgetown-core/ruby_template_view.rb +11 -11
- data/lib/bridgetown-core/site.rb +13 -6
- data/lib/bridgetown-core/static_file.rb +33 -10
- data/lib/bridgetown-core/tags/highlight.rb +2 -15
- data/lib/bridgetown-core/tags/include.rb +1 -1
- data/lib/bridgetown-core/tags/post_url.rb +2 -2
- data/lib/bridgetown-core/url.rb +1 -0
- data/lib/bridgetown-core/utils.rb +49 -43
- data/lib/bridgetown-core/utils/require_gems.rb +60 -0
- data/lib/bridgetown-core/utils/ruby_exec.rb +6 -9
- data/lib/bridgetown-core/utils/ruby_front_matter.rb +39 -0
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +2 -1
- data/lib/bridgetown-core/yaml_parser.rb +22 -0
- data/lib/site_template/config/.keep +0 -0
- data/lib/site_template/package.json.erb +4 -4
- data/lib/site_template/plugins/site_builder.rb +1 -1
- data/lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb +1 -1
- metadata +46 -41
- data/lib/bridgetown-core/external.rb +0 -58
- data/lib/bridgetown-core/page_without_a_file.rb +0 -17
- data/lib/bridgetown-core/path_manager.rb +0 -31
- data/lib/bridgetown-core/readers/collection_reader.rb +0 -23
- data/lib/bridgetown-core/readers/static_file_reader.rb +0 -25
- data/lib/bridgetown-core/utils/exec.rb +0 -26
- data/lib/bridgetown-core/utils/internet.rb +0 -37
- data/lib/bridgetown-core/utils/platforms.rb +0 -80
- data/lib/bridgetown-core/utils/thread_event.rb +0 -31
- data/lib/bridgetown-core/utils/win_tz.rb +0 -75
@@ -25,6 +25,15 @@ module Bridgetown
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
desc "dream", "There's a place where that idea still exists as a reality"
|
29
|
+
def dream
|
30
|
+
puts ""
|
31
|
+
puts "🎶 The Dream of the 90s is Alive in Portland... ✨"
|
32
|
+
puts " https://youtu.be/U4hShMEk1Ew"
|
33
|
+
puts " https://youtu.be/0_HGqPGp9iY"
|
34
|
+
puts ""
|
35
|
+
end
|
36
|
+
|
28
37
|
desc "help <command>", "Show detailed command usage information and exit"
|
29
38
|
def help(subcommand = nil)
|
30
39
|
if subcommand && respond_to?(subcommand)
|
@@ -79,17 +79,6 @@ module Bridgetown
|
|
79
79
|
#
|
80
80
|
# Returns nothing.
|
81
81
|
def watch_site(config_options)
|
82
|
-
# Warn Windows users that they might need to upgrade.
|
83
|
-
if Utils::Platforms.bash_on_windows?
|
84
|
-
Bridgetown.logger.warn "",
|
85
|
-
"Auto-regeneration may not work on some Windows versions."
|
86
|
-
Bridgetown.logger.warn "",
|
87
|
-
"Please see: https://github.com/Microsoft/BashOnWindows/issues/216"
|
88
|
-
Bridgetown.logger.warn "",
|
89
|
-
"If it does not work, please upgrade Bash on Windows or "\
|
90
|
-
"run Bridgetown with --no-watch."
|
91
|
-
end
|
92
|
-
|
93
82
|
Bridgetown::Watcher.watch(@site, config_options)
|
94
83
|
end
|
95
84
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
module Commands
|
5
|
+
module GitHelpers
|
6
|
+
def initialize_new_repo
|
7
|
+
run "git init", abort_on_failure: true
|
8
|
+
`git symbolic-ref HEAD refs/heads/main` if user_default_branch.empty?
|
9
|
+
end
|
10
|
+
|
11
|
+
def destroy_existing_repo
|
12
|
+
run "rm -rf .git"
|
13
|
+
end
|
14
|
+
|
15
|
+
def user_default_branch
|
16
|
+
@user_default_branch ||= `git config init.defaultbranch`.strip
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -4,6 +4,7 @@ module Bridgetown
|
|
4
4
|
module Commands
|
5
5
|
class Configure < Thor::Group
|
6
6
|
include Thor::Actions
|
7
|
+
include Actions
|
7
8
|
extend Summarizable
|
8
9
|
|
9
10
|
Registrations.register do
|
@@ -20,13 +21,13 @@ module Bridgetown
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def perform_configurations
|
23
|
-
logger = Bridgetown.logger
|
24
|
+
@logger = Bridgetown.logger
|
24
25
|
list_configurations if args.empty?
|
25
26
|
|
26
27
|
args.each do |configuration|
|
27
28
|
configure configuration
|
28
29
|
rescue Thor::Error
|
29
|
-
logger.error "Error:".red, "🚨 Configuration doesn't exist: #{configuration}"
|
30
|
+
@logger.error "Error:".red, "🚨 Configuration doesn't exist: #{configuration}"
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
@@ -40,7 +41,7 @@ module Bridgetown
|
|
40
41
|
configuration_file = find_in_source_paths("#{configuration}.rb")
|
41
42
|
|
42
43
|
inside(New.created_site_dir || Dir.pwd) do
|
43
|
-
|
44
|
+
apply configuration_file, verbose: false
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
@@ -50,6 +51,10 @@ module Bridgetown
|
|
50
51
|
configuration = set_color configuration, :blue, :bold
|
51
52
|
say configuration
|
52
53
|
end
|
54
|
+
say "\n"
|
55
|
+
|
56
|
+
docs_url = "https://www.bridgetownrb.com/docs/bundled-configurations".yellow.bold
|
57
|
+
say "For more info, check out the docs at: #{docs_url}"
|
53
58
|
end
|
54
59
|
|
55
60
|
def configurations
|
@@ -28,6 +28,7 @@ module Bridgetown
|
|
28
28
|
|
29
29
|
def console
|
30
30
|
require "irb"
|
31
|
+
require "irb/ext/save-history"
|
31
32
|
require "amazing_print" unless options[:"bypass-ap"]
|
32
33
|
|
33
34
|
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
|
@@ -50,6 +51,7 @@ module Bridgetown
|
|
50
51
|
IRB.setup(nil)
|
51
52
|
workspace = IRB::WorkSpace.new
|
52
53
|
irb = IRB::Irb.new(workspace)
|
54
|
+
IRB.conf[:IRB_RC]&.call(irb.context)
|
53
55
|
IRB.conf[:MAIN_CONTEXT] = irb.context
|
54
56
|
eval("site = $BRIDGETOWN_SITE", workspace.binding, __FILE__, __LINE__)
|
55
57
|
Bridgetown.logger.info "Console:", "Now loaded as " + "site".cyan + " variable."
|
@@ -68,6 +70,8 @@ module Bridgetown
|
|
68
70
|
end
|
69
71
|
irb.eval_input
|
70
72
|
end
|
73
|
+
ensure
|
74
|
+
IRB.conf[:AT_EXIT].each(&:call)
|
71
75
|
end
|
72
76
|
end
|
73
77
|
end
|
@@ -33,7 +33,6 @@ module Bridgetown
|
|
33
33
|
|
34
34
|
def healthy?(site)
|
35
35
|
[
|
36
|
-
fsnotify_buggy?(site),
|
37
36
|
!conflicting_urls(site),
|
38
37
|
!urls_only_differ_by_case(site),
|
39
38
|
proper_site_url?(site),
|
@@ -59,7 +58,7 @@ module Bridgetown
|
|
59
58
|
conflicting_urls = false
|
60
59
|
urls = {}
|
61
60
|
urls = collect_urls(urls, site.pages, site.dest)
|
62
|
-
urls = collect_urls(urls, site.posts.docs, site.dest)
|
61
|
+
urls = collect_urls(urls, site.collections.posts.docs, site.dest)
|
63
62
|
urls.each do |url, paths|
|
64
63
|
next unless paths.size > 1
|
65
64
|
|
@@ -70,23 +69,6 @@ module Bridgetown
|
|
70
69
|
conflicting_urls
|
71
70
|
end
|
72
71
|
|
73
|
-
def fsnotify_buggy?(_site)
|
74
|
-
return true unless Utils::Platforms.osx?
|
75
|
-
|
76
|
-
if Dir.pwd != `pwd`.strip
|
77
|
-
Bridgetown.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ")
|
78
|
-
We have detected that there might be trouble using fsevent on your
|
79
|
-
operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug)
|
80
|
-
for possible work arounds or you can work around it immediately
|
81
|
-
with `--force-polling`.
|
82
|
-
STR
|
83
|
-
|
84
|
-
false
|
85
|
-
end
|
86
|
-
|
87
|
-
true
|
88
|
-
end
|
89
|
-
|
90
72
|
def urls_only_differ_by_case(site)
|
91
73
|
urls_only_differ_by_case = false
|
92
74
|
urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
|
@@ -4,6 +4,7 @@ module Bridgetown
|
|
4
4
|
module Commands
|
5
5
|
class New < Thor::Group
|
6
6
|
include Thor::Actions
|
7
|
+
include GitHelpers
|
7
8
|
extend Summarizable
|
8
9
|
|
9
10
|
Registrations.register do
|
@@ -85,10 +86,10 @@ module Bridgetown
|
|
85
86
|
)
|
86
87
|
template("Gemfile.erb", "Gemfile")
|
87
88
|
template("package.json.erb", "package.json")
|
88
|
-
template("webpack.config.js.erb", "webpack.config.js")
|
89
89
|
template("frontend/javascript/index.js.erb", "frontend/javascript/index.js")
|
90
90
|
|
91
91
|
options["use-postcss"] ? configure_postcss : configure_sass
|
92
|
+
invoke(Webpack, ["setup"], {})
|
92
93
|
end
|
93
94
|
|
94
95
|
def configure_sass
|
@@ -139,7 +140,7 @@ module Bridgetown
|
|
139
140
|
# rubocop:enable Metrics/PerceivedComplexity
|
140
141
|
|
141
142
|
def bundle_install(path)
|
142
|
-
unless Bridgetown.environment
|
143
|
+
unless Bridgetown.environment.test?
|
143
144
|
require "bundler"
|
144
145
|
Bridgetown.with_unbundled_env do
|
145
146
|
inside(path) do
|
@@ -155,10 +156,9 @@ module Bridgetown
|
|
155
156
|
end
|
156
157
|
|
157
158
|
def git_init(path)
|
158
|
-
unless Bridgetown.environment
|
159
|
+
unless Bridgetown.environment.test?
|
159
160
|
inside(path) do
|
160
|
-
|
161
|
-
run "if [[ -n $(git status | grep 'On branch master') ]]; then git checkout -b main; fi"
|
161
|
+
initialize_new_repo
|
162
162
|
end
|
163
163
|
end
|
164
164
|
rescue SystemExit
|
@@ -166,7 +166,7 @@ module Bridgetown
|
|
166
166
|
end
|
167
167
|
|
168
168
|
def yarn_install(path)
|
169
|
-
unless Bridgetown.environment
|
169
|
+
unless Bridgetown.environment.test?
|
170
170
|
inside(path) do
|
171
171
|
run "yarn install", abort_on_failure: true
|
172
172
|
end
|
@@ -5,6 +5,7 @@ module Bridgetown
|
|
5
5
|
class Plugins < Thor
|
6
6
|
include Thor::Actions
|
7
7
|
include ConfigurationOverridable
|
8
|
+
include GitHelpers
|
8
9
|
|
9
10
|
Registrations.register do
|
10
11
|
desc "plugins <command>", "List installed plugins or access plugin content"
|
@@ -144,15 +145,15 @@ module Bridgetown
|
|
144
145
|
name = folder_name.dasherize
|
145
146
|
module_name = folder_name.camelize
|
146
147
|
|
147
|
-
|
148
|
+
# TODO: upon 0.21 release, remove the explicit branch name!
|
149
|
+
run "git clone -b switch-to-minitest https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}"
|
148
150
|
new_gemspec = "#{name}.gemspec"
|
149
151
|
|
150
152
|
inside name do # rubocop:todo Metrics/BlockLength
|
151
|
-
|
152
|
-
|
153
|
-
run "if [[ -n $(git status | grep 'On branch master') ]]; then git checkout -b main; fi"
|
153
|
+
destroy_existing_repo
|
154
|
+
initialize_new_repo
|
154
155
|
|
155
|
-
|
156
|
+
FileUtils.mv "bridgetown-sample-plugin.gemspec", new_gemspec.to_s
|
156
157
|
gsub_file new_gemspec, "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}"
|
157
158
|
gsub_file new_gemspec, "bridgetown-sample-plugin", name
|
158
159
|
gsub_file new_gemspec, "sample-plugin", name
|
@@ -161,21 +162,21 @@ module Bridgetown
|
|
161
162
|
gsub_file "package.json", "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}"
|
162
163
|
gsub_file "package.json", "bridgetown-sample-plugin", name
|
163
164
|
|
164
|
-
|
165
|
+
FileUtils.mv "lib/sample-plugin.rb", "lib/#{name}.rb"
|
165
166
|
gsub_file "lib/#{name}.rb", "sample-plugin", name
|
166
167
|
gsub_file "lib/#{name}.rb", "SamplePlugin", module_name
|
167
168
|
|
168
|
-
|
169
|
+
FileUtils.mv "lib/sample-plugin", "lib/#{name}"
|
169
170
|
gsub_file "lib/#{name}/builder.rb", "SamplePlugin", module_name
|
170
171
|
gsub_file "lib/#{name}/version.rb", "SamplePlugin", module_name
|
171
172
|
|
172
|
-
|
173
|
-
gsub_file "
|
174
|
-
gsub_file "
|
173
|
+
FileUtils.mv "test/test_sample_plugin.rb", "test/test_#{folder_name}.rb"
|
174
|
+
gsub_file "test/test_#{folder_name}.rb", "SamplePlugin", module_name
|
175
|
+
gsub_file "test/helper.rb", "sample-plugin", name
|
175
176
|
|
176
|
-
|
177
|
-
|
178
|
-
|
177
|
+
FileUtils.mv "components/sample_plugin", "components/#{folder_name}"
|
178
|
+
FileUtils.mv "content/sample_plugin", "content/#{folder_name}"
|
179
|
+
FileUtils.mv "layouts/sample_plugin", "layouts/#{folder_name}"
|
179
180
|
|
180
181
|
gsub_file "layouts/#{folder_name}/layout.html", "sample_plugin", folder_name
|
181
182
|
gsub_file "content/#{folder_name}/example_page.md", "sample_plugin", folder_name
|
@@ -13,10 +13,6 @@ module Bridgetown
|
|
13
13
|
|
14
14
|
class_option :host, aliases: "-H", desc: "Host to bind to"
|
15
15
|
class_option :port, aliases: "-P", desc: "Port to listen on"
|
16
|
-
class_option :open_url,
|
17
|
-
aliases: "-o",
|
18
|
-
type: :boolean,
|
19
|
-
desc: "Launch your site in a browser"
|
20
16
|
class_option :detach,
|
21
17
|
aliases: "-B",
|
22
18
|
type: :boolean,
|
@@ -169,16 +165,6 @@ module Bridgetown
|
|
169
165
|
)
|
170
166
|
end
|
171
167
|
|
172
|
-
def launch_browser(server, opts)
|
173
|
-
address = server_address(server, opts)
|
174
|
-
return system "start", address if Utils::Platforms.windows?
|
175
|
-
return system "xdg-open", address if Utils::Platforms.linux?
|
176
|
-
return system "open", address if Utils::Platforms.osx?
|
177
|
-
|
178
|
-
Bridgetown.logger.error "Refusing to launch browser; " \
|
179
|
-
"Platform launcher unknown."
|
180
|
-
end
|
181
|
-
|
182
168
|
# Keep in our area with a thread or detach the server as requested
|
183
169
|
# by the user. This method determines what we do based on what you
|
184
170
|
# ask us to do.
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
module Commands
|
5
|
+
class Webpack < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
extend Summarizable
|
8
|
+
|
9
|
+
Registrations.register do
|
10
|
+
register(Webpack, "webpack", "webpack ACTION", Webpack.summary)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.banner
|
14
|
+
"bridgetown webpack ACTION"
|
15
|
+
end
|
16
|
+
summary "Perform actions on the bridgetown webpack configuration"
|
17
|
+
|
18
|
+
def self.exit_on_failure?
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def webpack
|
23
|
+
@logger = Bridgetown.logger
|
24
|
+
return show_actions if args.empty?
|
25
|
+
|
26
|
+
action = args.first
|
27
|
+
if supported_actions.include?(action)
|
28
|
+
perform action
|
29
|
+
else
|
30
|
+
@logger.error "Error:".red, "🚨 Please enter a valid action."
|
31
|
+
say "\n"
|
32
|
+
show_actions
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.source_root
|
37
|
+
File.expand_path("./webpack", __dir__)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.destination_root
|
41
|
+
config.root_dir
|
42
|
+
end
|
43
|
+
|
44
|
+
def config
|
45
|
+
@config ||= Bridgetown.configuration({ root_dir: Dir.pwd })
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def perform(action)
|
51
|
+
automation = find_in_source_paths("#{action}.rb")
|
52
|
+
inside(New.created_site_dir || Dir.pwd) do
|
53
|
+
apply automation, verbose: false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def show_actions
|
58
|
+
say "Available actions:\n".bold
|
59
|
+
|
60
|
+
longest_action = supported_actions.keys.max_by(&:size).size
|
61
|
+
supported_actions.each do |action, description|
|
62
|
+
say action.ljust(longest_action).to_s.bold.blue + "\t" + "# #{description}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def supported_actions
|
67
|
+
{
|
68
|
+
setup: "Sets up a webpack integration with Bridgetown in your project",
|
69
|
+
update: "Updates the Bridgetown webpack defaults to the latest available version",
|
70
|
+
"enable-postcss": "Configures PostCSS in your project",
|
71
|
+
}.with_indifferent_access
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
default_postcss_config = File.expand_path("../../../site_template/postcss.config.js.erb", __dir__)
|
4
|
+
|
5
|
+
template default_postcss_config, "postcss.config.js"
|
6
|
+
template "webpack.defaults.js.erb", "config/webpack.defaults.js", force: true
|
7
|
+
|
8
|
+
unless Bridgetown.environment.test?
|
9
|
+
packages = %w(postcss@8.3.0 postcss-loader@4.3.0 postcss-flexbugs-fixes postcss-preset-env)
|
10
|
+
run "yarn add -D #{packages.join(" ")}"
|
11
|
+
run "yarn remove sass sass-loader"
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
const config = require("./config/webpack.defaults.js")
|
2
|
+
|
3
|
+
// Add any overrides to the default webpack config here:
|
4
|
+
|
5
|
+
// Eg:
|
6
|
+
//
|
7
|
+
// ```
|
8
|
+
// const path = require("path")
|
9
|
+
// config.resolve.modules.push(path.resolve(__dirname, 'frontend', 'components'))
|
10
|
+
// config.resolve.alias.frontendComponents = path.resolve(__dirname, 'frontend', 'components')
|
11
|
+
// ```
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
////////////////////////////////////////////////////////
|
17
|
+
|
18
|
+
module.exports = config
|
@@ -1,9 +1,22 @@
|
|
1
|
+
// This file is created and managed by Bridgetown.
|
2
|
+
// Instead of editing this file, add your overrides to `webpack.config.js`
|
3
|
+
//
|
4
|
+
// To update this file to the latest version provided by Bridgetown,
|
5
|
+
// run `bridgetown webpack update`. Any changes to this file will be overwritten
|
6
|
+
// when an update is applied hence we strongly recommend adding overrides to
|
7
|
+
// `webpack.config.js` instead of editing this file.
|
8
|
+
//
|
9
|
+
// Shipped with Bridgetown v<%= Bridgetown::VERSION %>
|
10
|
+
|
1
11
|
const path = require("path");
|
12
|
+
const rootDir = path.resolve(__dirname, "..")
|
2
13
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
3
14
|
const ManifestPlugin = require("webpack-manifest-plugin");
|
4
15
|
|
5
16
|
module.exports = {
|
6
|
-
entry:
|
17
|
+
entry: {
|
18
|
+
main: path.resolve(rootDir, "frontend", "javascript", "index.js")
|
19
|
+
},
|
7
20
|
devtool: "source-map",
|
8
21
|
// Set some or all of these to true if you want more verbose logging:
|
9
22
|
stats: {
|
@@ -13,26 +26,26 @@ module.exports = {
|
|
13
26
|
children: false,
|
14
27
|
},
|
15
28
|
output: {
|
16
|
-
path: path.resolve(
|
17
|
-
filename: "
|
29
|
+
path: path.resolve(rootDir, "output", "_bridgetown", "static", "js"),
|
30
|
+
filename: "[name].[contenthash].js",
|
18
31
|
},
|
19
32
|
resolve: {
|
20
33
|
extensions: [".js", ".jsx"],
|
21
34
|
modules: [
|
22
|
-
path.resolve(
|
23
|
-
path.resolve(
|
24
|
-
path.resolve('
|
35
|
+
path.resolve(rootDir, 'frontend', 'javascript'),
|
36
|
+
path.resolve(rootDir, 'frontend', 'styles'),
|
37
|
+
path.resolve(rootDir, 'node_modules')
|
25
38
|
],
|
26
39
|
alias: {
|
27
|
-
bridgetownComponents: path.resolve(
|
40
|
+
bridgetownComponents: path.resolve(rootDir, "src", "_components")
|
28
41
|
}
|
29
42
|
},
|
30
43
|
plugins: [
|
31
44
|
new MiniCssExtractPlugin({
|
32
|
-
filename: "../css/
|
45
|
+
filename: "../css/[name].[contenthash].css",
|
33
46
|
}),
|
34
47
|
new ManifestPlugin({
|
35
|
-
fileName: path.resolve(
|
48
|
+
fileName: path.resolve(rootDir, ".bridgetown-webpack", "manifest.json"),
|
36
49
|
}),
|
37
50
|
],
|
38
51
|
module: {
|
@@ -52,11 +65,12 @@ module.exports = {
|
|
52
65
|
helpers: false,
|
53
66
|
},
|
54
67
|
],
|
68
|
+
["@babel/plugin-proposal-private-methods", { "loose": true }],
|
55
69
|
],
|
56
70
|
},
|
57
71
|
},
|
58
72
|
},
|
59
|
-
<% if
|
73
|
+
<% if self.config.uses_postcss? %>
|
60
74
|
{
|
61
75
|
test: /\.(s[ac]|c)ss$/,
|
62
76
|
use: [
|
@@ -70,7 +84,7 @@ module.exports = {
|
|
70
84
|
},
|
71
85
|
"postcss-loader"
|
72
86
|
],
|
73
|
-
},
|
87
|
+
},
|
74
88
|
<% else %>
|
75
89
|
{
|
76
90
|
test: /\.(s[ac]|c)ss$/,
|
@@ -85,9 +99,11 @@ module.exports = {
|
|
85
99
|
{
|
86
100
|
loader: "sass-loader",
|
87
101
|
options: {
|
102
|
+
implementation: require("sass"),
|
88
103
|
sassOptions: {
|
104
|
+
fiber: false,
|
89
105
|
includePaths: [
|
90
|
-
path.resolve(
|
106
|
+
path.resolve(rootDir, "src/_components")
|
91
107
|
],
|
92
108
|
},
|
93
109
|
},
|
@@ -108,11 +124,11 @@ module.exports = {
|
|
108
124
|
test: /\.png?$|\.gif$|\.jpg$|\.svg$/,
|
109
125
|
loader: "file-loader",
|
110
126
|
options: {
|
111
|
-
name: "[name]-[contenthash].[ext]",
|
112
|
-
outputPath: "../
|
113
|
-
publicPath: "../
|
127
|
+
name: "[path][name]-[contenthash].[ext]",
|
128
|
+
outputPath: "../",
|
129
|
+
publicPath: "../",
|
114
130
|
},
|
115
131
|
},
|
116
132
|
],
|
117
133
|
},
|
118
|
-
};
|
134
|
+
};
|