Skip to content

Commit

Permalink
Add config directory and move webpack defaults into it (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushn21 authored May 25, 2021
1 parent 8f087e3 commit 485e6f1
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true

template "webpack.defaults.js.erb", "webpack.defaults.js"
template "webpack.defaults.js.erb", "config/webpack.defaults.js"
copy_file "webpack.config.js", force: true
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

template "webpack.defaults.js.erb", "webpack.defaults.js", force: true
template "webpack.defaults.js.erb", "config/webpack.defaults.js", force: true
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const config = require("./webpack.defaults.js")
const config = require("./config/webpack.defaults.js")

// Add any overrides to the default webpack config here:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
// `webpack.config.js` instead of editing this file.

const path = require("path");
const rootDir = path.resolve(__dirname, "..")
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const ManifestPlugin = require("webpack-manifest-plugin");

module.exports = {
entry: {
main: "./frontend/javascript/index.js"
main: path.resolve(rootDir, "frontend", "javascript", "index.js")
},
devtool: "source-map",
// Set some or all of these to true if you want more verbose logging:
Expand All @@ -23,26 +24,26 @@ module.exports = {
children: false,
},
output: {
path: path.resolve(__dirname, "output", "_bridgetown", "static", "js"),
path: path.resolve(rootDir, "output", "_bridgetown", "static", "js"),
filename: "[name].[contenthash].js",
},
resolve: {
extensions: [".js", ".jsx"],
modules: [
path.resolve(__dirname, 'frontend', 'javascript'),
path.resolve(__dirname, 'frontend', 'styles'),
path.resolve('./node_modules')
path.resolve(rootDir, 'frontend', 'javascript'),
path.resolve(rootDir, 'frontend', 'styles'),
path.resolve(rootDir, 'node_modules')
],
alias: {
bridgetownComponents: path.resolve(__dirname, "src", "_components")
bridgetownComponents: path.resolve(rootDir, "src", "_components")
}
},
plugins: [
new MiniCssExtractPlugin({
filename: "../css/[name].[contenthash].css",
}),
new ManifestPlugin({
fileName: path.resolve(__dirname, ".bridgetown-webpack", "manifest.json"),
fileName: path.resolve(rootDir, ".bridgetown-webpack", "manifest.json"),
}),
],
module: {
Expand Down Expand Up @@ -100,7 +101,7 @@ module.exports = {
sassOptions: {
fiber: false,
includePaths: [
path.resolve(__dirname, "src/_components")
path.resolve(rootDir, "src/_components")
],
},
},
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion bridgetown-core/test/test_new_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def site_template_source
end

def template_config_files
["/Gemfile", "/package.json", "/frontend/javascript/index.js", "/webpack.config.js", "/webpack.defaults.js"]
["/Gemfile", "/package.json", "/frontend/javascript/index.js", "/webpack.config.js", "/config/webpack.defaults.js"]
end

def static_template_files
Expand Down
3 changes: 1 addition & 2 deletions bridgetown-core/test/test_webpack_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class TestWebpackCommand < BridgetownUnitTest
def webpack_defaults
File.join(@full_path, "webpack.defaults.js")
File.join(@full_path, "config", "webpack.defaults.js")
end

def webpack_config
Expand Down Expand Up @@ -53,7 +53,6 @@ def webpack_config
end

should "update webpack config" do
webpack_defaults = File.join(@full_path, "webpack.defaults.js")
File.write(webpack_defaults, "OLD_VERSION")

@cmd.inside(@full_path) do
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-website/src/_docs/frontend-assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ category: frontendassets

Bridgetown comes with a default configuration of [Webpack](https://webpack.js.org) to handle building and exporting frontend assets such as JavaScript/TypeScript/etc., CSS/Sass/etc., and related files that are imported through Webpack (fonts, icons, etc.)

The default configuration is defined in `webpack.defaults.js`. You can add or override config options in `webpack.config.js`.
The default configuration is defined in `config/webpack.defaults.js`. You can add or override config options in `webpack.config.js`.

The default configuration can be updated to the latest version provided by Bridgetown using the `webpack` CLI tool:

Expand Down

0 comments on commit 485e6f1

Please sign in to comment.