bridgetown-core 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ceaadbfc504f5ac87f7ffbca7b5b87ed2967f564a12ca69f577f9d3a5216cf4
4
- data.tar.gz: be1d543b08eb98d7e02f7f0eb00d0e31d112363601f716956e140e1949f09d8e
3
+ metadata.gz: 31902453cc98a9dd7477a25c07f005b5f4faecbd69bf45e166d13c7ff9406c79
4
+ data.tar.gz: 5d9d919d9f2d13c0a6f572d166057c437e1e996ea7f5658972fc31f5e7cb539c
5
5
  SHA512:
6
- metadata.gz: 9e7b7feb4ee52314b2ca52893c22484e2419f0af871519e8f5417b04cc8dce91bf1b65931a993b0ae46c7c62a7ee77fabd8c210ec2f1cac4b21af6ce6d14a22e
7
- data.tar.gz: c4e9971e2887f3c2490c21a7207d684fa6c8194e5c27b7a375f81a7aca79d0b42632f96b7a6762e25c6749be22976cba84c234d2b176d92082f342c5e8465369
6
+ metadata.gz: 54a5ad80eccbc1702bd5743afa6eb78cb3e5c5615495acbe7fe178c55447ef3ae45bdd7be8aae6e89278258f8c2cbc86ec6a826f79a15a41b38b7c2ad498d815
7
+ data.tar.gz: b6504df792cb0804cfb0a0feba76c90da44e63a38d325d40f5b543cb616ba06b5ce26ea957b883404d65bfbbefeb539e1170654d00cc4ff9144e25e260acd931
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ module Tags
5
+ class WebpackPath < Liquid::Tag
6
+ include Bridgetown::Filters::URLFilters
7
+
8
+ def initialize(tag_name, asset_type, tokens)
9
+ super
10
+
11
+ # js or css
12
+ @asset_type = asset_type.strip
13
+ end
14
+
15
+ def render(context)
16
+ @context = context
17
+ site = context.registers[:site]
18
+
19
+ frontend_path = relative_url("_bridgetown/static")
20
+
21
+ manifest_file = site.in_root_dir(".bridgetown-webpack", "manifest.json")
22
+ if File.exist?(manifest_file)
23
+ manifest = JSON.parse(File.read(manifest_file))
24
+ if @asset_type == "js"
25
+ js_path = manifest["main.js"].split("/").last
26
+ [frontend_path, "js", js_path].join("/")
27
+ elsif @asset_type == "css"
28
+ css_path = manifest["main.css"].split("/").last
29
+ [frontend_path, "css", css_path].join("/")
30
+ else
31
+ Bridgetown.logger.error("Unknown Webpack asset type", @asset_type)
32
+ nil
33
+ end
34
+ else
35
+ "MISSING_WEBPACK_MANIFEST"
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ Liquid::Template.register_tag("webpack_path", Bridgetown::Tags::WebpackPath)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "0.10.0"
4
+ VERSION = "0.10.1"
5
5
  end
@@ -37,8 +37,11 @@ module Bridgetown
37
37
  private
38
38
 
39
39
  def build_listener(site, options)
40
+ webpack_path = site.in_root_dir(".bridgetown-webpack")
41
+ FileUtils.mkdir(webpack_path) unless Dir.exist?(webpack_path)
40
42
  Listen.to(
41
43
  options["source"],
44
+ site.in_root_dir(".bridgetown-webpack"),
42
45
  ignore: listen_ignore_paths(options),
43
46
  force_polling: options["force_polling"],
44
47
  &listen_handler(site)
@@ -54,7 +57,7 @@ module Bridgetown
54
57
  Bridgetown.logger.info "Regenerating…"
55
58
  Bridgetown.logger.info "", "#{n} file(s) changed at #{t.strftime("%Y-%m-%d %H:%M:%S")}"
56
59
 
57
- c.each { |path| Bridgetown.logger.info "", path["#{site.source}/".length..-1] }
60
+ c.each { |path| Bridgetown.logger.info "", path["#{site.root_dir}/".length..-1] }
58
61
  process(site, t)
59
62
  end
60
63
  end
@@ -3,4 +3,5 @@ node_modules
3
3
  .sass-cache
4
4
  .bridgetown-cache
5
5
  .bridgetown-metadata
6
+ .bridgetown-webpack
6
7
  vendor
@@ -19,6 +19,7 @@
19
19
  "sass-loader": "^8.0.2",
20
20
  "style-loader": "^1.1.3",
21
21
  "webpack": "^4.42.1",
22
- "webpack-cli": "^3.3.11"
22
+ "webpack-cli": "^3.3.11",
23
+ "webpack-manifest-plugin": "^2.2.0"
23
24
  }
24
25
  }
@@ -5,5 +5,5 @@
5
5
 
6
6
  <meta name="description" content="{{ site.metadata.description }}" />
7
7
 
8
- <link rel="stylesheet" href="/_bridgetown/static/css/all.css{% if bridgetown.environment == 'development' %}?{{ site.time | date: '%I%M%s' }}{% endif %}" />
9
- <script src="/_bridgetown/static/js/all.js{% if bridgetown.environment == 'development' %}?{{ site.time | date: '%I%M%s' }}{% endif %}"></script>
8
+ <link rel="stylesheet" href="{% webpack_path css %}" />
9
+ <script src="{% webpack_path js %}" defer></script>
@@ -1,19 +1,30 @@
1
- const path = require('path');
2
- const MiniCssExtractPlugin = require("mini-css-extract-plugin");
1
+ const path = require("path")
2
+ const MiniCssExtractPlugin = require("mini-css-extract-plugin")
3
+ const ManifestPlugin = require("webpack-manifest-plugin")
3
4
 
4
5
  module.exports = {
5
- entry: './frontend/javascript/index.js',
6
+ entry: "./frontend/javascript/index.js",
6
7
  devtool: "source-map",
8
+ // Set some or all of these to true if you want more verbose logging:
9
+ stats: {
10
+ modules: false,
11
+ builtAt: false,
12
+ timings: false,
13
+ children: false
14
+ },
7
15
  output: {
8
- path: path.resolve(__dirname, 'output', '_bridgetown', 'static', 'js'),
9
- filename: 'all.js'
16
+ path: path.resolve(__dirname, "output", "_bridgetown", "static", "js"),
17
+ filename: "all.[contenthash].js"
10
18
  },
11
19
  resolve: {
12
- extensions: ['.js']
20
+ extensions: [".js"]
13
21
  },
14
22
  plugins: [
15
23
  new MiniCssExtractPlugin({
16
- filename: "../css/all.css",
24
+ filename: "../css/all.[contenthash].css",
25
+ }),
26
+ new ManifestPlugin({
27
+ fileName: path.resolve(__dirname, ".bridgetown-webpack", "manifest.json")
17
28
  })
18
29
  ],
19
30
  module: {
@@ -21,13 +32,13 @@ module.exports = {
21
32
  {
22
33
  test: /\.js/,
23
34
  use: {
24
- loader: 'babel-loader',
35
+ loader: "babel-loader",
25
36
  options: {
26
37
  presets: [
27
- '@babel/preset-env'
38
+ "@babel/preset-env"
28
39
  ],
29
40
  plugins: [
30
- '@babel/plugin-proposal-class-properties'
41
+ "@babel/plugin-proposal-class-properties"
31
42
  ]
32
43
  }
33
44
  }
@@ -36,12 +47,12 @@ module.exports = {
36
47
  test: /\.(sc|c)ss$/,
37
48
  use: [
38
49
  MiniCssExtractPlugin.loader,
39
- 'css-loader',
50
+ "css-loader",
40
51
  {
41
- loader: 'sass-loader',
52
+ loader: "sass-loader",
42
53
  options: {
43
54
  sassOptions: {
44
- includePaths: [path.resolve(__dirname, 'src/_includes')]
55
+ includePaths: [path.resolve(__dirname, "src/_includes")]
45
56
  }
46
57
  }
47
58
  }
@@ -49,12 +60,12 @@ module.exports = {
49
60
  },
50
61
  {
51
62
  test: /\.woff2?$|\.ttf$|\.eot$|\.svg$/,
52
- loader: 'file-loader',
63
+ loader: "file-loader",
53
64
  options: {
54
- outputPath: '../fonts',
55
- publicPath: '../fonts'
65
+ outputPath: "../fonts",
66
+ publicPath: "../fonts"
56
67
  },
57
68
  }
58
69
  ]
59
70
  }
60
- };
71
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-18 00:00:00.000000000 Z
11
+ date: 2020-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -264,6 +264,7 @@ files:
264
264
  - lib/bridgetown-core/tags/link.rb
265
265
  - lib/bridgetown-core/tags/post_url.rb
266
266
  - lib/bridgetown-core/tags/render_content.rb
267
+ - lib/bridgetown-core/tags/webpack_path.rb
267
268
  - lib/bridgetown-core/url.rb
268
269
  - lib/bridgetown-core/utils.rb
269
270
  - lib/bridgetown-core/utils/ansi.rb