From dc1e53970b9d532ed3b3e483b1dfb59bb8f3a960 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sat, 20 May 2017 13:38:39 +0100 Subject: [PATCH 01/27] Consolidate yml config into one file webpacker.yml Setup eager_load Minor cleanup Remove behind the scenes Update template installer Use filename Install webpack loader as dependency Fix spacing Add watchtoptions Remove hot Remove ARGV for dev server Put back colors Oops use nil Use cheap-module-source-map Minor cleanup Refactor Change to default_settings --- CHANGELOG.md | 4 +- README.md | 15 +++--- lib/install/bin/webpack-dev-server.tt | 29 ++++++----- lib/install/bin/webpack.tt | 20 ++++---- lib/install/config/webpack/configuration.js | 7 ++- lib/install/config/webpack/development.js | 17 ++++++- .../config/webpack/development.server.js | 17 ------- .../config/webpack/development.server.yml | 17 ------- lib/install/config/webpack/paths.yml | 33 ------------ lib/install/config/webpack/shared.js | 4 +- lib/install/config/webpacker.yml | 51 +++++++++++++++++++ lib/install/elm.rb | 6 +-- lib/install/template.rb | 14 +++-- lib/tasks/webpacker/verify_install.rake | 2 +- lib/webpacker/configuration.rb | 32 +++++++----- lib/webpacker/env.rb | 4 +- test/configuration_test.rb | 2 +- test/env_test.rb | 2 +- test/webpacker_test.rb | 1 + 19 files changed, 146 insertions(+), 131 deletions(-) delete mode 100644 lib/install/config/webpack/development.server.js delete mode 100644 lib/install/config/webpack/development.server.yml delete mode 100644 lib/install/config/webpack/paths.yml create mode 100644 lib/install/config/webpacker.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 27b1d5381..857934eda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,11 +12,11 @@ - New app: `rails new --webpack=elm` - Within an existing app: `rails webpacker:install:elm` -- Support for custom `output` paths independent of `entry` in `paths.yml`. `output` is also now relative to `public/`. - [#397](https://github.com/rails/webpacker/pull/397) +- Support for custom `output` paths independent of `entry` in `config/webpacker.yml`. `output` is also now relative to `public/`. - [#397](https://github.com/rails/webpacker/pull/397) Before (compile to `public/packs`): ```yaml - entry: packs + entry: packs output: public ``` After (compile to `public/sweet/js`): diff --git a/README.md b/README.md index 9ed33ee39..bc9226688 100644 --- a/README.md +++ b/README.md @@ -101,32 +101,29 @@ and ## Advanced Configuration By default, webpacker offers simple conventions for where the webpack configs, javascript app files and compiled webpack bundles will go in your rails app, -but all these options are configurable from `config/webpack/paths.yml` file. +but all these options are configurable from `config/webpacker.yml` file. ```yml -# config/webpack/paths.yml +# config/webpacker.yml source: app/javascript entry: packs output: public config: config/webpack -node_modules: node_modules ``` -*Note:* Behind the scenes, webpacker will use same `entry` directory name inside `output` -directory to emit bundles. For ex, `public/packs` - Similary, you can also control and configure `webpack-dev-server` settings from -`config/webpack/development.server.yml` file +`config/webpacker.yml` file ```yml -# config/webpack/development.server.yml +# config/webpacker.yml enabled: true host: localhost port: 8080 +https: false ``` By default, `webpack-dev-server` uses `output` option specified in -`paths.yml` as `contentBase`. +`webpacker.yml` as `contentBase`. ## Linking to static assets diff --git a/lib/install/bin/webpack-dev-server.tt b/lib/install/bin/webpack-dev-server.tt index 3a736fc96..ecafe6081 100644 --- a/lib/install/bin/webpack-dev-server.tt +++ b/lib/install/bin/webpack-dev-server.tt @@ -10,25 +10,30 @@ RAILS_ENV = ENV["RAILS_ENV"] ENV["NODE_ENV"] ||= RAILS_ENV NODE_ENV = ENV["NODE_ENV"] -APP_PATH = File.expand_path("../", __dir__) +APP_PATH = File.expand_path("../", __dir__) +CONFIG_FILE = File.join(APP_PATH, "config/webpacker.yml") +NODE_MODULES_PATH = File.join(APP_PATH, "node_modules") + +begin + yaml_config = YAML.load_file(CONFIG_FILE)[NODE_ENV] + paths = yaml_config["paths"] + dev_server = yaml_config["devServer"] + + WEBPACK_CONFIG = File.join(APP_PATH, paths["config"], "development.js") + DEV_SERVER_HOST = "http#{"s" if dev_server["https"]}://#{dev_server["host"]}:#{dev_server["port"]}" -def load_yaml_config(config_file) - YAML.load_file(File.join(APP_PATH, config_file))[NODE_ENV] rescue Errno::ENOENT, NoMethodError - puts "Configuration not found in #{config_file}." + puts "Configuration not found in #{CONFIG_FILE}." puts "Please run bundle exec rails webpacker:install to install webpacker" exit! end -paths = load_yaml_config("config/webpack/paths.yml") -NODE_MODULES_PATH = File.join(APP_PATH, paths["node_modules"]) -WEBPACK_CONFIG = File.join(APP_PATH, paths["config"], "development.server.js") - -dev_server = load_yaml_config("config/webpack/development.server.yml") -DEV_SERVER_HOST = "http#{"s" if dev_server["https"]}://#{dev_server["host"]}:#{dev_server["port"]}" +newenv = { + "NODE_PATH" => NODE_MODULES_PATH.shellescape, + "ASSET_HOST" => DEV_SERVER_HOST.shellescape +}.freeze -newenv = { "NODE_PATH" => NODE_MODULES_PATH.shellescape, "ASSET_HOST" => DEV_SERVER_HOST.shellescape } -cmdline = ["yarn", "run", "webpack-dev-server", "--", "--progress", "--color", "--config", WEBPACK_CONFIG] + ARGV +cmdline = ["yarn", "run", "webpack-dev-server", "--", "--progress", "--color", "--config", WEBPACK_CONFIG] Dir.chdir(APP_PATH) do exec newenv, *cmdline diff --git a/lib/install/bin/webpack.tt b/lib/install/bin/webpack.tt index 09371db1a..c5b967ec9 100644 --- a/lib/install/bin/webpack.tt +++ b/lib/install/bin/webpack.tt @@ -10,21 +10,23 @@ RAILS_ENV = ENV["RAILS_ENV"] ENV["NODE_ENV"] ||= RAILS_ENV NODE_ENV = ENV["NODE_ENV"] -APP_PATH = File.expand_path("../", __dir__) +APP_PATH = File.expand_path("../", __dir__) +CONFIG_FILE = File.join(APP_PATH, "config/webpacker.yml") +NODE_MODULES_PATH = File.join(APP_PATH, "node_modules") + +begin + yaml_config = YAML.load_file(CONFIG_FILE)[NODE_ENV] + paths = yaml_config["paths"] + + WEBPACK_CONFIG = File.join(APP_PATH, paths["config"], "#{NODE_ENV}.js") -def load_yaml_config(config_file) - YAML.load_file(File.join(APP_PATH, config_file))[NODE_ENV] rescue Errno::ENOENT, NoMethodError - puts "Configuration not found in #{config_file}." + puts "Configuration not found in #{CONFIG_FILE}." puts "Please run bundle exec rails webpacker:install to install webpacker" exit! end -paths = load_yaml_config("config/webpack/paths.yml") -NODE_MODULES_PATH = File.join(APP_PATH, paths["node_modules"]) -WEBPACK_CONFIG = File.join(APP_PATH, paths["config"], "#{NODE_ENV}.js") - -newenv = { "NODE_PATH" => NODE_MODULES_PATH.shellescape } +newenv = { "NODE_PATH" => NODE_MODULES_PATH.shellescape } cmdline = ["yarn", "run", "webpack", "--", "--config", WEBPACK_CONFIG] + ARGV Dir.chdir(APP_PATH) do diff --git a/lib/install/config/webpack/configuration.js b/lib/install/config/webpack/configuration.js index 4f55505a8..3427cf040 100644 --- a/lib/install/config/webpack/configuration.js +++ b/lib/install/config/webpack/configuration.js @@ -1,14 +1,13 @@ -// Common configuration for webpacker loaded from config/webpack/paths.yml +// Common configuration for webpacker loaded from config/webpacker.yml const { join, resolve } = require('path') const { env } = require('process') const { safeLoad } = require('js-yaml') const { readFileSync } = require('fs') -const configPath = resolve('config', 'webpack') +const configPath = resolve('config', 'webpacker.yml') const loadersDir = join(__dirname, 'loaders') -const paths = safeLoad(readFileSync(join(configPath, 'paths.yml'), 'utf8'))[env.NODE_ENV] -const devServer = safeLoad(readFileSync(join(configPath, 'development.server.yml'), 'utf8'))[env.NODE_ENV] +const { paths, devServer } = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV] function removeOuterSlashes(string) { return string.replace(/^\/*/, '').replace(/\/*$/, '') diff --git a/lib/install/config/webpack/development.js b/lib/install/config/webpack/development.js index 7dfa2df11..39f6d9b7f 100644 --- a/lib/install/config/webpack/development.js +++ b/lib/install/config/webpack/development.js @@ -2,9 +2,10 @@ const merge = require('webpack-merge') const sharedConfig = require('./shared.js') +const { devServer, output } = require('./configuration.js') module.exports = merge(sharedConfig, { - devtool: 'sourcemap', + devtool: 'cheap-module-source-map', stats: { errorDetails: true @@ -12,5 +13,19 @@ module.exports = merge(sharedConfig, { output: { pathinfo: true + }, + + devServer: { + clientLogLevel: 'none', + host: devServer.host, + port: devServer.port, + contentBase: output.path, + publicPath: output.publicPath, + compress: true, + headers: { 'Access-Control-Allow-Origin': '*' }, + historyApiFallback: true, + watchOptions: { + ignored: /node_modules/ + } } }) diff --git a/lib/install/config/webpack/development.server.js b/lib/install/config/webpack/development.server.js deleted file mode 100644 index 08dfff1e4..000000000 --- a/lib/install/config/webpack/development.server.js +++ /dev/null @@ -1,17 +0,0 @@ -// Note: You must restart bin/webpack-dev-server for changes to take effect - -const merge = require('webpack-merge') -const devConfig = require('./development.js') -const { devServer, output } = require('./configuration.js') - -module.exports = merge(devConfig, { - devServer: { - host: devServer.host, - port: devServer.port, - contentBase: output.path, - publicPath: output.publicPath, - compress: true, - headers: { 'Access-Control-Allow-Origin': '*' }, - historyApiFallback: true - } -}) diff --git a/lib/install/config/webpack/development.server.yml b/lib/install/config/webpack/development.server.yml deleted file mode 100644 index ee588a888..000000000 --- a/lib/install/config/webpack/development.server.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Note: You must restart bin/webpack-dev-server for changes to take effect - -default: &default - enabled: true - host: localhost - port: 8080 - -development: - <<: *default - -test: - <<: *default - enabled: false - -production: - <<: *default - enabled: false diff --git a/lib/install/config/webpack/paths.yml b/lib/install/config/webpack/paths.yml deleted file mode 100644 index 5c3550ccf..000000000 --- a/lib/install/config/webpack/paths.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Note: You must restart bin/webpack-dev-server for changes to take effect - -default: &default # ~ = Rails.root - source: app/javascript # ~/:source - entry: packs # ~/:source/:entry - output: packs # ~/public/:output - manifest: manifest.json # ~/public/:output/:manifest - config: config/webpack # ~/:config - node_modules: node_modules # ~/:node_modules - extensions: - - .coffee - - .js - - .jsx - - .ts - - .vue - - .sass - - .scss - - .css - - .png - - .svg - - .gif - - .jpeg - - .jpg - -development: - <<: *default - -test: - <<: *default - manifest: manifest-test.json - -production: - <<: *default diff --git a/lib/install/config/webpack/shared.js b/lib/install/config/webpack/shared.js index 53a0b5895..5d3de394e 100644 --- a/lib/install/config/webpack/shared.js +++ b/lib/install/config/webpack/shared.js @@ -48,11 +48,11 @@ module.exports = { extensions: paths.extensions, modules: [ resolve(paths.source), - resolve(paths.node_modules) + 'node_modules' ] }, resolveLoader: { - modules: [paths.node_modules] + modules: ['node_modules'] } } diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml new file mode 100644 index 000000000..719e22af0 --- /dev/null +++ b/lib/install/config/webpacker.yml @@ -0,0 +1,51 @@ +# Note: You must restart bin/webpack-dev-server for changes to take effect + +default: &default + devServer: # https://webpack.js.org/configuration/dev-server/ + enabled: true # Enabled by default in development + host: localhost # Dev server host + port: 8080 + https: false + + paths: # ~ = Rails.root + source: app/javascript # ~/:source + entry: packs # ~/:source/:entry + output: packs # ~/public/:output + manifest: manifest.json # ~/public/:output/:manifest + config: config/webpack # ~/:config + + extensions: + - .coffee + - .js + - .jsx + - .ts + - .vue + - .sass + - .scss + - .css + - .png + - .svg + - .gif + - .jpeg + - .jpg + +development: + <<: *default + +test: + <<: *default + + devServer: + enabled: false + + paths: + manifest: manifest-test.json + +production: + <<: *default + + devServer: + host: example.com + port: + enabled: false + https: true diff --git a/lib/install/elm.rb b/lib/install/elm.rb index 9bbf68f79..8930e6bfd 100644 --- a/lib/install/elm.rb +++ b/lib/install/elm.rb @@ -12,12 +12,12 @@ "#{Webpacker::Configuration.entry_path}/hello_elm.js" puts "Installing all elm dependencies" -run "yarn add elm" -run "yarn add --dev elm-hot-loader elm-webpack-loader" +run "yarn add elm elm-webpack-loader" +run "yarn add --dev elm-hot-loader" run "yarn run elm package install -- --yes" puts "Updating Webpack paths to include Elm file extension" -insert_into_file Webpacker::Configuration.file_path, " - .elm\n", after: /extensions:\n/ +insert_into_file Webpacker::Configuration.file_path, " - .elm\n", after: /extensions:\n/ puts "Updating elm source location" source_path = File.join Webpacker::Configuration.source, Webpacker::Configuration.paths.fetch(:entry, "packs") diff --git a/lib/install/template.rb b/lib/install/template.rb index 2d65b3e4c..73fd6487b 100644 --- a/lib/install/template.rb +++ b/lib/install/template.rb @@ -1,11 +1,19 @@ # Install webpacker +copy_file "#{__dir__}/config/webpacker.yml", "config/webpacker.yml" + puts "Copying webpack core config and loaders" directory "#{__dir__}/config/webpack", "config/webpack" directory "#{__dir__}/config/loaders/core", "config/webpack/loaders" -copy_file "#{__dir__}/config/.postcssrc.yml", ".postcssrc.yml" -puts "Copying .babelrc to app root directory" -copy_file "#{__dir__}/config/.babelrc", ".babelrc" +unless File.exist?(".postcssrc.yml") + puts "Copying .postcssrc.yml to app root directory" + copy_file "#{__dir__}/config/.postcssrc.yml", ".postcssrc.yml" +end + +unless File.exist?(".babelrc") + puts "Copying .babelrc to app root directory" + copy_file "#{__dir__}/config/.babelrc", ".babelrc" +end puts "Creating javascript app source directory" directory "#{__dir__}/javascript", "#{Webpacker::Configuration.source}" diff --git a/lib/tasks/webpacker/verify_install.rake b/lib/tasks/webpacker/verify_install.rake index ff7896254..b6d80b446 100644 --- a/lib/tasks/webpacker/verify_install.rake +++ b/lib/tasks/webpacker/verify_install.rake @@ -7,7 +7,7 @@ namespace :webpacker do puts "Webpacker is installed 🎉 🍰" puts "Using #{Webpacker::Configuration.file_path} file for setting up webpack paths" else - puts "Configuration config/webpack/paths.yml file not found. \n"\ + puts "Configuration config/webpacker.yml file not found. \n"\ "Make sure webpacker:install is run successfully before " \ "running dependent tasks" exit! diff --git a/lib/webpacker/configuration.rb b/lib/webpacker/configuration.rb index ad330ef2f..70121bb15 100644 --- a/lib/webpacker/configuration.rb +++ b/lib/webpacker/configuration.rb @@ -1,19 +1,19 @@ -# Loads webpacker configuration from config/webpack/paths.yml +# Loads webpacker configuration from config/webpacker.yml require "webpacker/file_loader" class Webpacker::Configuration < Webpacker::FileLoader class << self def entry_path - source_path.join(fetch(:entry)) + source_path.join(paths[:entry]) end def output_path - public_path.join(fetch(:output)) + public_path.join(paths[:output]) end def manifest_path - output_path.join(fetch(:manifest)) + output_path.join(paths[:manifest]) end def source_path @@ -25,11 +25,11 @@ def public_path end def config_path - Rails.root.join(fetch(:config)) + Rails.root.join(paths[:config]) end def file_path(root: Rails.root) - root.join("config/webpack/paths.yml") + root.join("config/webpacker.yml") end def default_file_path @@ -37,21 +37,25 @@ def default_file_path end def source - fetch(:source) + paths[:source] end - def fetch(key) - paths.fetch(key, default_paths[key]) - end - - def paths + def data load if Webpacker.env.development? raise Webpacker::FileLoader::FileLoaderError.new("Webpacker::Configuration.load must be called first") unless instance instance.data end - def default_paths - @default_paths ||= HashWithIndifferentAccess.new(YAML.load(default_file_path.read)["default"]) + def paths + data.fetch(:paths, default_settings(key: "paths")) + end + + def dev_server + data.fetch(:devServer, default_settings(key: "devServer")) + end + + def default_settings(key: "paths") + @default_settings ||= HashWithIndifferentAccess.new(YAML.load(default_file_path.read)["default"][key]) end end diff --git a/lib/webpacker/env.rb b/lib/webpacker/env.rb index 147def958..f7a385e37 100644 --- a/lib/webpacker/env.rb +++ b/lib/webpacker/env.rb @@ -1,4 +1,4 @@ -# Singleton registry for determining NODE_ENV from config/webpack/paths.yml +# Singleton registry for determining NODE_ENV from config/webpacker.yml require "webpacker/file_loader" class Webpacker::Env < Webpacker::FileLoader @@ -9,7 +9,7 @@ def current end def file_path - Rails.root.join("config", "webpack", "paths.yml") + Rails.root.join("config", "webpacker.yml") end end diff --git a/test/configuration_test.rb b/test/configuration_test.rb index f3bc51356..58d79d90b 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -12,7 +12,7 @@ def test_entry_path end def test_file_path - file_path = File.join(File.dirname(__FILE__), "test_app/config", "webpack", "paths.yml").to_s + file_path = File.join(File.dirname(__FILE__), "test_app/config", "webpacker.yml").to_s assert_equal Webpacker::Configuration.file_path.to_s, file_path end diff --git a/test/env_test.rb b/test/env_test.rb index abc102f44..ae058ddf5 100644 --- a/test/env_test.rb +++ b/test/env_test.rb @@ -8,7 +8,7 @@ def test_current_env end def test_file_path - correct_path = File.join(File.dirname(__FILE__), "test_app/config", "webpack", "paths.yml").to_s + correct_path = File.join(File.dirname(__FILE__), "test_app/config", "webpacker.yml").to_s assert_equal Webpacker::Env.file_path.to_s, correct_path end end diff --git a/test/webpacker_test.rb b/test/webpacker_test.rb index 18e6cee58..f05871147 100644 --- a/test/webpacker_test.rb +++ b/test/webpacker_test.rb @@ -8,6 +8,7 @@ module TestApp class Application < ::Rails::Application config.root = File.join(File.dirname(__FILE__), "test_app") + config.eager_load = true end end From eaa505654028ad2785d2a94283d195d4fe40b47b Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 14:43:50 +0100 Subject: [PATCH 02/27] Remove enabled --- README.md | 1 - lib/install/config/webpacker.yml | 5 ----- 2 files changed, 6 deletions(-) diff --git a/README.md b/README.md index bc9226688..c26e084e1 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,6 @@ Similary, you can also control and configure `webpack-dev-server` settings from ```yml # config/webpacker.yml -enabled: true host: localhost port: 8080 https: false diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml index 719e22af0..f6c46b7ec 100644 --- a/lib/install/config/webpacker.yml +++ b/lib/install/config/webpacker.yml @@ -2,7 +2,6 @@ default: &default devServer: # https://webpack.js.org/configuration/dev-server/ - enabled: true # Enabled by default in development host: localhost # Dev server host port: 8080 https: false @@ -35,9 +34,6 @@ development: test: <<: *default - devServer: - enabled: false - paths: manifest: manifest-test.json @@ -47,5 +43,4 @@ production: devServer: host: example.com port: - enabled: false https: true From f03ed3123a12ffa4ed02b91cb1108da992b8cd91 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 15:00:46 +0100 Subject: [PATCH 03/27] Change case and move extension out of paths --- lib/install/bin/webpack-dev-server.tt | 2 +- lib/install/config/webpack/configuration.js | 5 +-- lib/install/config/webpack/development.js | 6 ++-- lib/install/config/webpack/shared.js | 6 ++-- lib/install/config/webpacker.yml | 34 ++++++++++----------- lib/install/elm.rb | 2 +- lib/webpacker/configuration.rb | 2 +- 7 files changed, 29 insertions(+), 28 deletions(-) diff --git a/lib/install/bin/webpack-dev-server.tt b/lib/install/bin/webpack-dev-server.tt index ecafe6081..38854b678 100644 --- a/lib/install/bin/webpack-dev-server.tt +++ b/lib/install/bin/webpack-dev-server.tt @@ -17,7 +17,7 @@ NODE_MODULES_PATH = File.join(APP_PATH, "node_modules") begin yaml_config = YAML.load_file(CONFIG_FILE)[NODE_ENV] paths = yaml_config["paths"] - dev_server = yaml_config["devServer"] + dev_server = yaml_config["dev_server"] WEBPACK_CONFIG = File.join(APP_PATH, paths["config"], "development.js") DEV_SERVER_HOST = "http#{"s" if dev_server["https"]}://#{dev_server["host"]}:#{dev_server["port"]}" diff --git a/lib/install/config/webpack/configuration.js b/lib/install/config/webpack/configuration.js index 3427cf040..f31d2bc64 100644 --- a/lib/install/config/webpack/configuration.js +++ b/lib/install/config/webpack/configuration.js @@ -7,7 +7,7 @@ const { readFileSync } = require('fs') const configPath = resolve('config', 'webpacker.yml') const loadersDir = join(__dirname, 'loaders') -const { paths, devServer } = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV] +const { dev_server, extensions, paths } = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV] function removeOuterSlashes(string) { return string.replace(/^\/*/, '').replace(/\/*$/, '') @@ -28,8 +28,9 @@ const output = { } module.exports = { - devServer, + dev_server, env, + extensions, paths, loadersDir, output diff --git a/lib/install/config/webpack/development.js b/lib/install/config/webpack/development.js index 39f6d9b7f..c00bb192f 100644 --- a/lib/install/config/webpack/development.js +++ b/lib/install/config/webpack/development.js @@ -2,7 +2,7 @@ const merge = require('webpack-merge') const sharedConfig = require('./shared.js') -const { devServer, output } = require('./configuration.js') +const { dev_server, output } = require('./configuration.js') module.exports = merge(sharedConfig, { devtool: 'cheap-module-source-map', @@ -17,8 +17,8 @@ module.exports = merge(sharedConfig, { devServer: { clientLogLevel: 'none', - host: devServer.host, - port: devServer.port, + host: dev_server.host, + port: dev_server.port, contentBase: output.path, publicPath: output.publicPath, compress: true, diff --git a/lib/install/config/webpack/shared.js b/lib/install/config/webpack/shared.js index 5d3de394e..a227bf685 100644 --- a/lib/install/config/webpack/shared.js +++ b/lib/install/config/webpack/shared.js @@ -9,9 +9,9 @@ const { sync } = require('glob') const ExtractTextPlugin = require('extract-text-webpack-plugin') const ManifestPlugin = require('webpack-manifest-plugin') const extname = require('path-complete-extname') -const { env, paths, output, loadersDir } = require('./configuration.js') +const { env, extensions, paths, output, loadersDir } = require('./configuration.js') -const extensionGlob = `**/*{${paths.extensions.join(',')}}*` +const extensionGlob = `**/*{${extensions.join(',')}}*` const packPaths = sync(join(paths.source, paths.entry, extensionGlob)) module.exports = { @@ -45,7 +45,7 @@ module.exports = { ], resolve: { - extensions: paths.extensions, + extensions, modules: [ resolve(paths.source), 'node_modules' diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml index f6c46b7ec..12831dd88 100644 --- a/lib/install/config/webpacker.yml +++ b/lib/install/config/webpacker.yml @@ -1,7 +1,7 @@ # Note: You must restart bin/webpack-dev-server for changes to take effect default: &default - devServer: # https://webpack.js.org/configuration/dev-server/ + dev_server: # https://webpack.js.org/configuration/dev-server/ host: localhost # Dev server host port: 8080 https: false @@ -13,20 +13,20 @@ default: &default manifest: manifest.json # ~/public/:output/:manifest config: config/webpack # ~/:config - extensions: - - .coffee - - .js - - .jsx - - .ts - - .vue - - .sass - - .scss - - .css - - .png - - .svg - - .gif - - .jpeg - - .jpg + extensions: + - .coffee + - .js + - .jsx + - .ts + - .vue + - .sass + - .scss + - .css + - .png + - .svg + - .gif + - .jpeg + - .jpg development: <<: *default @@ -40,7 +40,7 @@ test: production: <<: *default - devServer: - host: example.com + dev_server: + host: webpacker.dev port: https: true diff --git a/lib/install/elm.rb b/lib/install/elm.rb index 8930e6bfd..0665ed1ce 100644 --- a/lib/install/elm.rb +++ b/lib/install/elm.rb @@ -17,7 +17,7 @@ run "yarn run elm package install -- --yes" puts "Updating Webpack paths to include Elm file extension" -insert_into_file Webpacker::Configuration.file_path, " - .elm\n", after: /extensions:\n/ +insert_into_file Webpacker::Configuration.file_path, " - .elm\n", after: /extensions:\n/ puts "Updating elm source location" source_path = File.join Webpacker::Configuration.source, Webpacker::Configuration.paths.fetch(:entry, "packs") diff --git a/lib/webpacker/configuration.rb b/lib/webpacker/configuration.rb index 70121bb15..8e29cd611 100644 --- a/lib/webpacker/configuration.rb +++ b/lib/webpacker/configuration.rb @@ -51,7 +51,7 @@ def paths end def dev_server - data.fetch(:devServer, default_settings(key: "devServer")) + data.fetch(:dev_server, default_settings(key: "dev_server")) end def default_settings(key: "paths") From c877358d3b0cb8d960d857ae84bd80d68169723d Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 15:01:45 +0100 Subject: [PATCH 04/27] Change output directory for test --- lib/install/config/webpacker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml index 12831dd88..cdff5cf3d 100644 --- a/lib/install/config/webpacker.yml +++ b/lib/install/config/webpacker.yml @@ -35,6 +35,7 @@ test: <<: *default paths: + output: packs-test manifest: manifest-test.json production: From af4be41e34d4b1db3f2b462cd0f7899884a6c952 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 16:00:13 +0100 Subject: [PATCH 05/27] Add back argv --- lib/install/bin/webpack-dev-server.tt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/install/bin/webpack-dev-server.tt b/lib/install/bin/webpack-dev-server.tt index 38854b678..fd7085a0b 100644 --- a/lib/install/bin/webpack-dev-server.tt +++ b/lib/install/bin/webpack-dev-server.tt @@ -14,13 +14,18 @@ APP_PATH = File.expand_path("../", __dir__) CONFIG_FILE = File.join(APP_PATH, "config/webpacker.yml") NODE_MODULES_PATH = File.join(APP_PATH, "node_modules") +def args(key) + index = ARGV.index(key) + index ? ARGV[index + 1] : nil +end + begin yaml_config = YAML.load_file(CONFIG_FILE)[NODE_ENV] paths = yaml_config["paths"] dev_server = yaml_config["dev_server"] WEBPACK_CONFIG = File.join(APP_PATH, paths["config"], "development.js") - DEV_SERVER_HOST = "http#{"s" if dev_server["https"]}://#{dev_server["host"]}:#{dev_server["port"]}" + DEV_SERVER_HOST = "http#{"s" if args('--https') || dev_server["https"]}://#{args('--host') || dev_server["host"]}:#{args('--port') || dev_server["port"]}" rescue Errno::ENOENT, NoMethodError puts "Configuration not found in #{CONFIG_FILE}." @@ -33,7 +38,7 @@ newenv = { "ASSET_HOST" => DEV_SERVER_HOST.shellescape }.freeze -cmdline = ["yarn", "run", "webpack-dev-server", "--", "--progress", "--color", "--config", WEBPACK_CONFIG] +cmdline = ["yarn", "run", "webpack-dev-server", "--", "--progress", "--color", "--config", WEBPACK_CONFIG] + ARGV Dir.chdir(APP_PATH) do exec newenv, *cmdline From 58c428d7f03f0021668012dd41154c1f29ccf93a Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 16:12:49 +0100 Subject: [PATCH 06/27] Use 0.0.0.0 for cloud 9 --- lib/install/config/webpacker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml index cdff5cf3d..10d1018f8 100644 --- a/lib/install/config/webpacker.yml +++ b/lib/install/config/webpacker.yml @@ -42,6 +42,6 @@ production: <<: *default dev_server: - host: webpacker.dev - port: + host: 0.0.0.0 # Cloud9 + port: 8080 https: true From 17024665bec3d9a2e764b940cd32c5c40f2cc72b Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 16:13:35 +0100 Subject: [PATCH 07/27] Remove manifest overide since we don't use different output --- lib/install/config/webpacker.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml index 10d1018f8..eb41b754a 100644 --- a/lib/install/config/webpacker.yml +++ b/lib/install/config/webpacker.yml @@ -36,7 +36,6 @@ test: paths: output: packs-test - manifest: manifest-test.json production: <<: *default From 099f080f7745e26afa3c3486ca414ef41aaa33ed Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 16:19:57 +0100 Subject: [PATCH 08/27] Revert configuration.rb to use default path-per-key Fix typo --- lib/webpacker/configuration.rb | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/lib/webpacker/configuration.rb b/lib/webpacker/configuration.rb index 8e29cd611..ad94badce 100644 --- a/lib/webpacker/configuration.rb +++ b/lib/webpacker/configuration.rb @@ -5,15 +5,15 @@ class Webpacker::Configuration < Webpacker::FileLoader class << self def entry_path - source_path.join(paths[:entry]) + source_path.join(fetch(:entry)) end def output_path - public_path.join(paths[:output]) + public_path.join(fetch(:output)) end def manifest_path - output_path.join(paths[:manifest]) + output_path.join(fetch(:manifest)) end def source_path @@ -25,7 +25,7 @@ def public_path end def config_path - Rails.root.join(paths[:config]) + Rails.root.join(fetch(:config)) end def file_path(root: Rails.root) @@ -37,25 +37,21 @@ def default_file_path end def source - paths[:source] + fetch(:source) end - def data - load if Webpacker.env.development? - raise Webpacker::FileLoader::FileLoaderError.new("Webpacker::Configuration.load must be called first") unless instance - instance.data + def fetch(key) + paths.fetch(key, default_paths[key]) end def paths - data.fetch(:paths, default_settings(key: "paths")) - end - - def dev_server - data.fetch(:dev_server, default_settings(key: "dev_server")) + load if Webpacker.env.development? + raise Webpacker::FileLoader::FileLoaderError.new("Webpacker::Configuration.load must be called first") unless instance + instance.data end - def default_settings(key: "paths") - @default_settings ||= HashWithIndifferentAccess.new(YAML.load(default_file_path.read)["default"][key]) + def default_paths + @default_paths ||= HashWithIndifferentAccess.new(YAML.load(default_file_path.read)["default"]["paths"]) end end From a60d569e301d8e497233a1fefb2a322f623eae98 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 16:34:45 +0100 Subject: [PATCH 09/27] Add https to dev server --- lib/install/config/webpack/development.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/install/config/webpack/development.js b/lib/install/config/webpack/development.js index c00bb192f..a1e0b4530 100644 --- a/lib/install/config/webpack/development.js +++ b/lib/install/config/webpack/development.js @@ -19,6 +19,7 @@ module.exports = merge(sharedConfig, { clientLogLevel: 'none', host: dev_server.host, port: dev_server.port, + https: dev_server.https, contentBase: output.path, publicPath: output.publicPath, compress: true, From 32f18cda6cfb2d77fccbe2479e6da5001daab458 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 16:35:45 +0100 Subject: [PATCH 10/27] Move option up --- lib/install/config/webpack/development.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/install/config/webpack/development.js b/lib/install/config/webpack/development.js index a1e0b4530..676cce517 100644 --- a/lib/install/config/webpack/development.js +++ b/lib/install/config/webpack/development.js @@ -17,9 +17,9 @@ module.exports = merge(sharedConfig, { devServer: { clientLogLevel: 'none', + https: dev_server.https, host: dev_server.host, port: dev_server.port, - https: dev_server.https, contentBase: output.path, publicPath: output.publicPath, compress: true, From 91c6c7b668755859a21f81eed20e447b301ba2b0 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 17:12:18 +0100 Subject: [PATCH 11/27] Remove config and manifest option --- README.md | 1 - lib/install/bin/webpack-dev-server.tt | 3 +-- lib/install/bin/webpack.tt | 12 +++--------- lib/install/config/webpack/shared.js | 1 - lib/install/config/webpacker.yml | 2 -- lib/webpacker/configuration.rb | 2 +- 6 files changed, 5 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index c26e084e1..160807ce5 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,6 @@ but all these options are configurable from `config/webpacker.yml` file. source: app/javascript entry: packs output: public -config: config/webpack ``` Similary, you can also control and configure `webpack-dev-server` settings from diff --git a/lib/install/bin/webpack-dev-server.tt b/lib/install/bin/webpack-dev-server.tt index fd7085a0b..40ded5250 100644 --- a/lib/install/bin/webpack-dev-server.tt +++ b/lib/install/bin/webpack-dev-server.tt @@ -13,6 +13,7 @@ NODE_ENV = ENV["NODE_ENV"] APP_PATH = File.expand_path("../", __dir__) CONFIG_FILE = File.join(APP_PATH, "config/webpacker.yml") NODE_MODULES_PATH = File.join(APP_PATH, "node_modules") +WEBPACK_CONFIG = File.join(APP_PATH, "config/webpack/development.js") def args(key) index = ARGV.index(key) @@ -21,10 +22,8 @@ end begin yaml_config = YAML.load_file(CONFIG_FILE)[NODE_ENV] - paths = yaml_config["paths"] dev_server = yaml_config["dev_server"] - WEBPACK_CONFIG = File.join(APP_PATH, paths["config"], "development.js") DEV_SERVER_HOST = "http#{"s" if args('--https') || dev_server["https"]}://#{args('--host') || dev_server["host"]}:#{args('--port') || dev_server["port"]}" rescue Errno::ENOENT, NoMethodError diff --git a/lib/install/bin/webpack.tt b/lib/install/bin/webpack.tt index c5b967ec9..751da1318 100644 --- a/lib/install/bin/webpack.tt +++ b/lib/install/bin/webpack.tt @@ -11,17 +11,11 @@ ENV["NODE_ENV"] ||= RAILS_ENV NODE_ENV = ENV["NODE_ENV"] APP_PATH = File.expand_path("../", __dir__) -CONFIG_FILE = File.join(APP_PATH, "config/webpacker.yml") NODE_MODULES_PATH = File.join(APP_PATH, "node_modules") +WEBPACK_CONFIG = File.join(APP_PATH, "config/webpack/#{NODE_ENV}.js") -begin - yaml_config = YAML.load_file(CONFIG_FILE)[NODE_ENV] - paths = yaml_config["paths"] - - WEBPACK_CONFIG = File.join(APP_PATH, paths["config"], "#{NODE_ENV}.js") - -rescue Errno::ENOENT, NoMethodError - puts "Configuration not found in #{CONFIG_FILE}." +unless File.exist?(WEBPACK_CONFIG) + puts "Webpack configuration not found." puts "Please run bundle exec rails webpacker:install to install webpacker" exit! end diff --git a/lib/install/config/webpack/shared.js b/lib/install/config/webpack/shared.js index a227bf685..796503499 100644 --- a/lib/install/config/webpack/shared.js +++ b/lib/install/config/webpack/shared.js @@ -38,7 +38,6 @@ module.exports = { new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))), new ExtractTextPlugin(env.NODE_ENV === 'production' ? '[name]-[hash].css' : '[name].css'), new ManifestPlugin({ - fileName: paths.manifest, publicPath: output.publicPath, writeToFileEmit: true }) diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml index eb41b754a..214aaaf2c 100644 --- a/lib/install/config/webpacker.yml +++ b/lib/install/config/webpacker.yml @@ -10,8 +10,6 @@ default: &default source: app/javascript # ~/:source entry: packs # ~/:source/:entry output: packs # ~/public/:output - manifest: manifest.json # ~/public/:output/:manifest - config: config/webpack # ~/:config extensions: - .coffee diff --git a/lib/webpacker/configuration.rb b/lib/webpacker/configuration.rb index ad94badce..dd155244b 100644 --- a/lib/webpacker/configuration.rb +++ b/lib/webpacker/configuration.rb @@ -13,7 +13,7 @@ def output_path end def manifest_path - output_path.join(fetch(:manifest)) + output_path.join("manifest.json") end def source_path From abc53ac82a72c73752088fc8d7f404ef6987712c Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 17:17:04 +0100 Subject: [PATCH 12/27] Remove reference to config_path --- lib/install/angular.rb | 2 +- lib/install/elm.rb | 4 ++-- lib/install/react.rb | 2 +- lib/install/vue.rb | 2 +- lib/webpacker/configuration.rb | 4 ---- test/configuration_test.rb | 5 ----- 6 files changed, 5 insertions(+), 14 deletions(-) diff --git a/lib/install/angular.rb b/lib/install/angular.rb index 7d2dd7964..09112d028 100644 --- a/lib/install/angular.rb +++ b/lib/install/angular.rb @@ -1,6 +1,6 @@ require "webpacker/configuration" -puts "Copying angular loader to #{Webpacker::Configuration.config_path}/loaders" +puts "Copying angular loader to config/webpack/loaders" copy_file "#{__dir__}/config/loaders/installers/angular.js", "config/webpack/loaders/angular.js" puts "Copying angular example entry file to #{Webpacker::Configuration.entry_path}" diff --git a/lib/install/elm.rb b/lib/install/elm.rb index 0665ed1ce..a711b2c8f 100644 --- a/lib/install/elm.rb +++ b/lib/install/elm.rb @@ -1,8 +1,8 @@ require "webpacker/configuration" -puts "Copying elm loader to #{Webpacker::Configuration.config_path}/loaders" +puts "Copying elm loader to config/webpack/loaders" copy_file "#{__dir__}/config/loaders/installers/elm.js", - "#{Webpacker::Configuration.config_path}/loaders/elm.js" + "config/webpack/loaders/elm.js" puts "Copying elm example entry file to #{Webpacker::Configuration.entry_path}" copy_file "#{__dir__}/examples/elm/Main.elm", "#{Webpacker::Configuration.entry_path}/Main.elm" diff --git a/lib/install/react.rb b/lib/install/react.rb index c6e2dc374..9e16414de 100644 --- a/lib/install/react.rb +++ b/lib/install/react.rb @@ -19,7 +19,7 @@ copy_file "#{__dir__}/examples/react/.babelrc", ".babelrc" end -puts "Copying react loader to #{Webpacker::Configuration.config_path}/loaders" +puts "Copying react loader to config/webpack/loaders" copy_file "#{__dir__}/config/loaders/installers/react.js", "config/webpack/loaders/react.js" puts "Copying react example entry file to #{Webpacker::Configuration.entry_path}" diff --git a/lib/install/vue.rb b/lib/install/vue.rb index 71adb8c41..24f3c7ef7 100644 --- a/lib/install/vue.rb +++ b/lib/install/vue.rb @@ -1,6 +1,6 @@ require "webpacker/configuration" -puts "Copying vue loader to #{Webpacker::Configuration.config_path}/loaders" +puts "Copying vue loader to config/webpack/loaders" copy_file "#{__dir__}/config/loaders/installers/vue.js", "config/webpack/loaders/vue.js" puts "Copying the example entry file to #{Webpacker::Configuration.entry_path}" diff --git a/lib/webpacker/configuration.rb b/lib/webpacker/configuration.rb index dd155244b..ed5894d26 100644 --- a/lib/webpacker/configuration.rb +++ b/lib/webpacker/configuration.rb @@ -24,10 +24,6 @@ def public_path Rails.root.join("public") end - def config_path - Rails.root.join(fetch(:config)) - end - def file_path(root: Rails.root) root.join("config/webpacker.yml") end diff --git a/test/configuration_test.rb b/test/configuration_test.rb index 58d79d90b..133353076 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -1,11 +1,6 @@ require "webpacker_test" class ConfigurationTest < Minitest::Test - def test_config_path - config_path = File.join(File.dirname(__FILE__), "test_app/config", "webpack").to_s - assert_equal Webpacker::Configuration.config_path.to_s, config_path - end - def test_entry_path entry_path = File.join(File.dirname(__FILE__), "test_app/app/javascript", "packs").to_s assert_equal Webpacker::Configuration.entry_path.to_s, entry_path From 37706a94b7eedb7dde745b14e3b4dc5f979bbc3c Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 17:48:37 +0100 Subject: [PATCH 13/27] Flatten webpacker settings --- lib/install/bin/webpack-dev-server.tt | 5 ++--- lib/install/config/webpack/configuration.js | 10 ++++----- lib/install/config/webpack/development.js | 8 +++---- lib/install/config/webpack/shared.js | 9 ++++---- lib/install/config/webpacker.yml | 24 +++++++++------------ lib/install/elm.rb | 2 +- lib/webpacker/configuration.rb | 14 ++++++------ 7 files changed, 33 insertions(+), 39 deletions(-) diff --git a/lib/install/bin/webpack-dev-server.tt b/lib/install/bin/webpack-dev-server.tt index 40ded5250..77d37832e 100644 --- a/lib/install/bin/webpack-dev-server.tt +++ b/lib/install/bin/webpack-dev-server.tt @@ -21,10 +21,9 @@ def args(key) end begin - yaml_config = YAML.load_file(CONFIG_FILE)[NODE_ENV] - dev_server = yaml_config["dev_server"] + config = YAML.load_file(CONFIG_FILE)[NODE_ENV] - DEV_SERVER_HOST = "http#{"s" if args('--https') || dev_server["https"]}://#{args('--host') || dev_server["host"]}:#{args('--port') || dev_server["port"]}" + DEV_SERVER_HOST = "http#{"s" if args('--https') || config["dev_server_https"]}://#{args('--host') || config["dev_server_host"]}:#{args('--port') || config["dev_server_port"]}" rescue Errno::ENOENT, NoMethodError puts "Configuration not found in #{CONFIG_FILE}." diff --git a/lib/install/config/webpack/configuration.js b/lib/install/config/webpack/configuration.js index f31d2bc64..0d669ff0a 100644 --- a/lib/install/config/webpack/configuration.js +++ b/lib/install/config/webpack/configuration.js @@ -7,7 +7,7 @@ const { readFileSync } = require('fs') const configPath = resolve('config', 'webpacker.yml') const loadersDir = join(__dirname, 'loaders') -const { dev_server, extensions, paths } = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV] +const settings = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV] function removeOuterSlashes(string) { return string.replace(/^\/*/, '').replace(/\/*$/, '') @@ -23,15 +23,13 @@ function formatPublicPath(host = '', path = '') { } const output = { - path: resolve('public', paths.output), - publicPath: formatPublicPath(env.ASSET_HOST, paths.output) + path: resolve('public', settings.public_output_path), + publicPath: formatPublicPath(env.ASSET_HOST, settings.public_output_path) } module.exports = { - dev_server, + settings, env, - extensions, - paths, loadersDir, output } diff --git a/lib/install/config/webpack/development.js b/lib/install/config/webpack/development.js index 676cce517..df6b43f51 100644 --- a/lib/install/config/webpack/development.js +++ b/lib/install/config/webpack/development.js @@ -2,7 +2,7 @@ const merge = require('webpack-merge') const sharedConfig = require('./shared.js') -const { dev_server, output } = require('./configuration.js') +const { settings, output } = require('./configuration.js') module.exports = merge(sharedConfig, { devtool: 'cheap-module-source-map', @@ -17,9 +17,9 @@ module.exports = merge(sharedConfig, { devServer: { clientLogLevel: 'none', - https: dev_server.https, - host: dev_server.host, - port: dev_server.port, + https: settings.dev_server_https, + host: settings.dev_server_host, + port: settings.dev_server_port, contentBase: output.path, publicPath: output.publicPath, compress: true, diff --git a/lib/install/config/webpack/shared.js b/lib/install/config/webpack/shared.js index 796503499..e8040fff0 100644 --- a/lib/install/config/webpack/shared.js +++ b/lib/install/config/webpack/shared.js @@ -9,16 +9,17 @@ const { sync } = require('glob') const ExtractTextPlugin = require('extract-text-webpack-plugin') const ManifestPlugin = require('webpack-manifest-plugin') const extname = require('path-complete-extname') -const { env, extensions, paths, output, loadersDir } = require('./configuration.js') +const { env, extensions, settings, output, loadersDir } = require('./configuration.js') const extensionGlob = `**/*{${extensions.join(',')}}*` -const packPaths = sync(join(paths.source, paths.entry, extensionGlob)) +const entryPath = join(settings.source_path, settings.source_entry_path) +const packPaths = sync(join(entryPath, extensionGlob)) module.exports = { entry: packPaths.reduce( (map, entry) => { const localMap = map - const namespace = relative(join(paths.source, paths.entry), dirname(entry)) + const namespace = relative(join(entryPath), dirname(entry)) localMap[join(namespace, basename(entry, extname(entry)))] = resolve(entry) return localMap }, {} @@ -46,7 +47,7 @@ module.exports = { resolve: { extensions, modules: [ - resolve(paths.source), + resolve(settings.source_path), 'node_modules' ] }, diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml index 214aaaf2c..d43edf628 100644 --- a/lib/install/config/webpacker.yml +++ b/lib/install/config/webpacker.yml @@ -1,15 +1,13 @@ # Note: You must restart bin/webpack-dev-server for changes to take effect default: &default - dev_server: # https://webpack.js.org/configuration/dev-server/ - host: localhost # Dev server host - port: 8080 - https: false + dev_server_host: localhost + dev_server_port: 8080 + dev_server_https: false - paths: # ~ = Rails.root - source: app/javascript # ~/:source - entry: packs # ~/:source/:entry - output: packs # ~/public/:output + source_path: app/javascript + source_entry_path: packs + public_output_path: packs extensions: - .coffee @@ -32,13 +30,11 @@ development: test: <<: *default - paths: - output: packs-test + public_output_path: packs-test production: <<: *default - dev_server: - host: 0.0.0.0 # Cloud9 - port: 8080 - https: true + dev_server_host: 0.0.0.0 + dev_server_port: 8080 + dev_server_https: true diff --git a/lib/install/elm.rb b/lib/install/elm.rb index a711b2c8f..2465d9562 100644 --- a/lib/install/elm.rb +++ b/lib/install/elm.rb @@ -20,7 +20,7 @@ insert_into_file Webpacker::Configuration.file_path, " - .elm\n", after: /extensions:\n/ puts "Updating elm source location" -source_path = File.join Webpacker::Configuration.source, Webpacker::Configuration.paths.fetch(:entry, "packs") +source_path = File.join Webpacker::Configuration.source, Webpacker::Configuration.fetch(:source_entry_path, "packs") gsub_file "elm-package.json", /\"\.\"\n/, %("#{source_path}"\n) puts "Updating .gitignore to include elm-stuff folder" diff --git a/lib/webpacker/configuration.rb b/lib/webpacker/configuration.rb index ed5894d26..70c5c4be9 100644 --- a/lib/webpacker/configuration.rb +++ b/lib/webpacker/configuration.rb @@ -5,11 +5,11 @@ class Webpacker::Configuration < Webpacker::FileLoader class << self def entry_path - source_path.join(fetch(:entry)) + source_path.join(fetch(:source_entry_path)) end def output_path - public_path.join(fetch(:output)) + public_path.join(fetch(:public_output_path)) end def manifest_path @@ -33,21 +33,21 @@ def default_file_path end def source - fetch(:source) + fetch(:source_path) end def fetch(key) - paths.fetch(key, default_paths[key]) + data.fetch(key, defaults[key]) end - def paths + def data load if Webpacker.env.development? raise Webpacker::FileLoader::FileLoaderError.new("Webpacker::Configuration.load must be called first") unless instance instance.data end - def default_paths - @default_paths ||= HashWithIndifferentAccess.new(YAML.load(default_file_path.read)["default"]["paths"]) + def defaults + @defaults ||= HashWithIndifferentAccess.new(YAML.load(default_file_path.read)["default"]) end end From f76db0e39b5a016f0f28b81a3a6867951435f815 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 17:51:00 +0100 Subject: [PATCH 14/27] Fix extensions --- lib/install/config/webpack/shared.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/install/config/webpack/shared.js b/lib/install/config/webpack/shared.js index e8040fff0..d901cc6da 100644 --- a/lib/install/config/webpack/shared.js +++ b/lib/install/config/webpack/shared.js @@ -9,9 +9,9 @@ const { sync } = require('glob') const ExtractTextPlugin = require('extract-text-webpack-plugin') const ManifestPlugin = require('webpack-manifest-plugin') const extname = require('path-complete-extname') -const { env, extensions, settings, output, loadersDir } = require('./configuration.js') +const { env, settings, output, loadersDir } = require('./configuration.js') -const extensionGlob = `**/*{${extensions.join(',')}}*` +const extensionGlob = `**/*{${settings.extensions.join(',')}}*` const entryPath = join(settings.source_path, settings.source_entry_path) const packPaths = sync(join(entryPath, extensionGlob)) @@ -45,7 +45,7 @@ module.exports = { ], resolve: { - extensions, + extensions: settings.extensions, modules: [ resolve(settings.source_path), 'node_modules' From 1140244d3f9592f74527dca8f992a995c8824241 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 18:20:58 +0100 Subject: [PATCH 15/27] Update readme --- README.md | 12 ++++++------ lib/install/config/webpacker.yml | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 160807ce5..15495f995 100644 --- a/README.md +++ b/README.md @@ -105,9 +105,9 @@ but all these options are configurable from `config/webpacker.yml` file. ```yml # config/webpacker.yml -source: app/javascript -entry: packs -output: public +source_path: app/assets/javascript +source_entry_path: entries +public_output_path: entries ``` Similary, you can also control and configure `webpack-dev-server` settings from @@ -115,9 +115,9 @@ Similary, you can also control and configure `webpack-dev-server` settings from ```yml # config/webpacker.yml -host: localhost -port: 8080 -https: false +dev_server_host: localhost +dev_server_port: 8080 +dev_server_https: false ``` By default, `webpack-dev-server` uses `output` option specified in diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml index d43edf628..724583d0d 100644 --- a/lib/install/config/webpacker.yml +++ b/lib/install/config/webpacker.yml @@ -11,6 +11,7 @@ default: &default extensions: - .coffee + - .erb - .js - .jsx - .ts From f992607ddf3f4191874e50828aade95eaee2f2ca Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 18:25:24 +0100 Subject: [PATCH 16/27] Update changelog --- CHANGELOG.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 857934eda..7ee3ea5e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,18 +12,19 @@ - New app: `rails new --webpack=elm` - Within an existing app: `rails webpacker:install:elm` -- Support for custom `output` paths independent of `entry` in `config/webpacker.yml`. `output` is also now relative to `public/`. - [#397](https://github.com/rails/webpacker/pull/397) +- Support for custom `public_output_path` paths independent of `source_entry_path` in `config/webpacker.yml`. `output` is also now relative to `public/`. - [#397](https://github.com/rails/webpacker/pull/397) Before (compile to `public/packs`): ```yaml - entry: packs - output: public + source_entry_path: packs + public_output_path: packs ``` After (compile to `public/sweet/js`): ```yaml - entry: packs - output: sweet/js + source_entry_path: packs + public_output_path: sweet/js ``` +- Consolidate `paths.yml` and `development.server.yml` into one file - `config/webpacker.yml` - [#403](https://github.com/rails/webpacker/pull/403) ## [1.2] - 2017-04-27 Some of the changes made requires you to run below commands to install new changes. From 5e363f37c3b2b1e462c10ce50c49fa142b2a72a9 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 20:05:24 +0100 Subject: [PATCH 17/27] Use 0.0.0.0 for host --- lib/install/config/webpacker.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml index 724583d0d..5ce5035b7 100644 --- a/lib/install/config/webpacker.yml +++ b/lib/install/config/webpacker.yml @@ -1,7 +1,7 @@ # Note: You must restart bin/webpack-dev-server for changes to take effect default: &default - dev_server_host: localhost + dev_server_host: 0.0.0.0 dev_server_port: 8080 dev_server_https: false @@ -35,7 +35,3 @@ test: production: <<: *default - - dev_server_host: 0.0.0.0 - dev_server_port: 8080 - dev_server_https: true From bb19d26dee8db262675c19f6b1e5c3327a89e7e3 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 20:06:27 +0100 Subject: [PATCH 18/27] Fix typo --- lib/install/config/webpack/development.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/install/config/webpack/development.js b/lib/install/config/webpack/development.js index df6b43f51..dfd0b60b6 100644 --- a/lib/install/config/webpack/development.js +++ b/lib/install/config/webpack/development.js @@ -5,7 +5,7 @@ const sharedConfig = require('./shared.js') const { settings, output } = require('./configuration.js') module.exports = merge(sharedConfig, { - devtool: 'cheap-module-source-map', + devtool: 'cheap-eval-source-map', stats: { errorDetails: true From 6cdf5d0d8329fd0c4832539a96a66ed4f0aff58d Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 21:05:19 +0100 Subject: [PATCH 19/27] Move dev_server to development env --- README.md | 7 ++++--- lib/install/bin/webpack-dev-server.tt | 4 ++-- lib/install/config/webpack/development.js | 6 +++--- lib/install/config/webpacker.yml | 9 +++++---- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 15495f995..e8ebb0d75 100644 --- a/README.md +++ b/README.md @@ -115,9 +115,10 @@ Similary, you can also control and configure `webpack-dev-server` settings from ```yml # config/webpacker.yml -dev_server_host: localhost -dev_server_port: 8080 -dev_server_https: false +dev_server: + host: 0.0.0.0 + port: 8080 + https: false ``` By default, `webpack-dev-server` uses `output` option specified in diff --git a/lib/install/bin/webpack-dev-server.tt b/lib/install/bin/webpack-dev-server.tt index 77d37832e..a9982890a 100644 --- a/lib/install/bin/webpack-dev-server.tt +++ b/lib/install/bin/webpack-dev-server.tt @@ -21,9 +21,9 @@ def args(key) end begin - config = YAML.load_file(CONFIG_FILE)[NODE_ENV] + dev_server = YAML.load_file(CONFIG_FILE)["development"]["dev_server"] - DEV_SERVER_HOST = "http#{"s" if args('--https') || config["dev_server_https"]}://#{args('--host') || config["dev_server_host"]}:#{args('--port') || config["dev_server_port"]}" + DEV_SERVER_HOST = "http#{"s" if args('--https') || dev_server["https"]}://#{args('--host') || dev_server["host"]}:#{args('--port') || dev_server["port"]}" rescue Errno::ENOENT, NoMethodError puts "Configuration not found in #{CONFIG_FILE}." diff --git a/lib/install/config/webpack/development.js b/lib/install/config/webpack/development.js index dfd0b60b6..87772d84f 100644 --- a/lib/install/config/webpack/development.js +++ b/lib/install/config/webpack/development.js @@ -17,9 +17,9 @@ module.exports = merge(sharedConfig, { devServer: { clientLogLevel: 'none', - https: settings.dev_server_https, - host: settings.dev_server_host, - port: settings.dev_server_port, + https: settings.dev_server.https, + host: settings.dev_server.host, + port: settings.dev_server.port, contentBase: output.path, publicPath: output.publicPath, compress: true, diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml index 5ce5035b7..28f2b0221 100644 --- a/lib/install/config/webpacker.yml +++ b/lib/install/config/webpacker.yml @@ -1,10 +1,6 @@ # Note: You must restart bin/webpack-dev-server for changes to take effect default: &default - dev_server_host: 0.0.0.0 - dev_server_port: 8080 - dev_server_https: false - source_path: app/javascript source_entry_path: packs public_output_path: packs @@ -28,6 +24,11 @@ default: &default development: <<: *default + dev_server: + host: 0.0.0.0 + port: 8080 + https: false + test: <<: *default From 57e082cf782ca240339b4a499594eb6168dd3878 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 21:54:43 +0100 Subject: [PATCH 20/27] Change wording --- lib/install/bin/webpack-dev-server.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/install/bin/webpack-dev-server.tt b/lib/install/bin/webpack-dev-server.tt index a9982890a..58e1faad2 100644 --- a/lib/install/bin/webpack-dev-server.tt +++ b/lib/install/bin/webpack-dev-server.tt @@ -26,7 +26,7 @@ begin DEV_SERVER_HOST = "http#{"s" if args('--https') || dev_server["https"]}://#{args('--host') || dev_server["host"]}:#{args('--port') || dev_server["port"]}" rescue Errno::ENOENT, NoMethodError - puts "Configuration not found in #{CONFIG_FILE}." + puts "Webpack dev_server configuration not found in #{CONFIG_FILE}." puts "Please run bundle exec rails webpacker:install to install webpacker" exit! end From 30465032625fc096408f2dd58ac10f1005ee5300 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 21:59:03 +0100 Subject: [PATCH 21/27] Remove contentBase --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index e8ebb0d75..b469a4530 100644 --- a/README.md +++ b/README.md @@ -121,9 +121,6 @@ dev_server: https: false ``` -By default, `webpack-dev-server` uses `output` option specified in -`webpacker.yml` as `contentBase`. - ## Linking to static assets Static assets like images, fonts and stylesheets support is enabled out-of-box so, you can link them into your javascript app code and have them compiled automatically. From 9d3288aab9dfc98c2d55c95c5ee73d6b7c95c78f Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 21 May 2017 22:04:33 +0100 Subject: [PATCH 22/27] Fix typo --- lib/install/elm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/install/elm.rb b/lib/install/elm.rb index 2465d9562..033254436 100644 --- a/lib/install/elm.rb +++ b/lib/install/elm.rb @@ -20,7 +20,7 @@ insert_into_file Webpacker::Configuration.file_path, " - .elm\n", after: /extensions:\n/ puts "Updating elm source location" -source_path = File.join Webpacker::Configuration.source, Webpacker::Configuration.fetch(:source_entry_path, "packs") +source_path = File.join(Webpacker::Configuration.source, Webpacker::Configuration.fetch(:source_entry_path)) gsub_file "elm-package.json", /\"\.\"\n/, %("#{source_path}"\n) puts "Updating .gitignore to include elm-stuff folder" From bfab9850bc20160d7f9a84c04929484d2a035858 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Mon, 22 May 2017 16:16:15 +0100 Subject: [PATCH 23/27] Update changelog and fix compile task --- CHANGELOG.md | 23 ++++++++++++++++++++++- lib/tasks/webpacker/compile.rake | 24 ++++++++++++++---------- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ee3ea5e5..6d9f3d67c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## [Unreleased] + ### Fixed - Update `.babelrc` to fix compilation issues - [#306](https://github.com/rails/webpacker/issues/306) @@ -7,6 +9,9 @@ - Incorrect asset host when running `webpacker:compile` or `bin/webpack` in development mode - [#397](https://github.com/rails/webpacker/pull/397) +- Update `webpacker:compile` task to use `stdout` and `stderr` for better logging - [#395](https://github.com/rails/webpacker/issues/395) +- ARGV support for `webpack-dev-server` - [#286](https://github.com/rails/webpacker/issues/286) + ### Added - [Elm](http://elm-lang.org) support. You can now add Elm support via the following methods: - New app: `rails new --webpack=elm` @@ -24,7 +29,23 @@ source_entry_path: packs public_output_path: sweet/js ``` -- Consolidate `paths.yml` and `development.server.yml` into one file - `config/webpacker.yml` - [#403](https://github.com/rails/webpacker/pull/403) +- `https` option to use `https` mode, particularly on platforms like - https://community.c9.io/t/running-a-rails-app/1615 or locally - [#176](https://github.com/rails/webpacker/issues/176) + + +#### Breaking Change + +- Consolidate and flatten `paths.yml` and `development.server.yml` config into one file - `config/webpacker.yml` - [#403](https://github.com/rails/webpacker/pull/403). This is a breaking change and requires you to re-install webpacker and cleanup old configuration files. + + ```bash + bundle update webpacker + bundle exec rails webpacker:install + + # Remove old/unused configuration files + rm config/paths.yml + rm config/development.server.yml + rm config/development.server.js + ``` + ## [1.2] - 2017-04-27 Some of the changes made requires you to run below commands to install new changes. diff --git a/lib/tasks/webpacker/compile.rake b/lib/tasks/webpacker/compile.rake index 1ed5632d6..a49b442b6 100644 --- a/lib/tasks/webpacker/compile.rake +++ b/lib/tasks/webpacker/compile.rake @@ -1,22 +1,26 @@ +require "open3" require "webpacker/env" require "webpacker/configuration" -REGEX_MAP = /\A.*\.map\z/ namespace :webpacker do desc "Compile javascript packs using webpack for production with digests" task compile: ["webpacker:verify_install", :environment] do - puts "Compiling webpacker assets 🎉" + new_line = "\n\n" + puts "[Webpacker] Compiling assets 🎉" + new_line + asset_host = ActionController::Base.helpers.compute_asset_host - asset_env = asset_host ? "ASSET_HOST=#{asset_host}" : "" - result = `#{asset_env} NODE_ENV=#{Webpacker.env} ./bin/webpack --json` + env = { "NODE_ENV" => Webpacker.env, "ASSET_HOST" => asset_host }.freeze - unless $?.success? - puts JSON.parse(result)["errors"] - exit! $?.exitstatus - end + _, stderr_str, status = Open3.capture3(env, "./bin/webpack") - puts "Compiled digests for all packs in #{Webpacker::Configuration.entry_path}: " - puts JSON.parse(File.read(Webpacker::Configuration.manifest_path)) + if status.success? + puts "[Webpacker] Compiled digests for all packs in #{Webpacker::Configuration.entry_path}:" + new_line + puts JSON.parse(File.read(Webpacker::Configuration.manifest_path)) + else + $stderr.puts "[Webpacker] [FAIL]" + new_line + $stderr.puts stderr_str + exit! + end end end From c030cf987cbf095d5f5891f6318a6e529cb7a951 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Mon, 22 May 2017 16:19:26 +0100 Subject: [PATCH 24/27] Add a link break --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d9f3d67c..768da276a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Incorrect asset host when running `webpacker:compile` or `bin/webpack` in development mode - [#397](https://github.com/rails/webpacker/pull/397) - Update `webpacker:compile` task to use `stdout` and `stderr` for better logging - [#395](https://github.com/rails/webpacker/issues/395) + - ARGV support for `webpack-dev-server` - [#286](https://github.com/rails/webpacker/issues/286) ### Added @@ -29,6 +30,7 @@ source_entry_path: packs public_output_path: sweet/js ``` + - `https` option to use `https` mode, particularly on platforms like - https://community.c9.io/t/running-a-rails-app/1615 or locally - [#176](https://github.com/rails/webpacker/issues/176) From 6b607668f877d76efc35c8d614ec88528b1e56b3 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Mon, 22 May 2017 16:41:40 +0100 Subject: [PATCH 25/27] Print stdout alongside stderr --- lib/tasks/webpacker/compile.rake | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/tasks/webpacker/compile.rake b/lib/tasks/webpacker/compile.rake index a49b442b6..fb3a8bb70 100644 --- a/lib/tasks/webpacker/compile.rake +++ b/lib/tasks/webpacker/compile.rake @@ -11,14 +11,15 @@ namespace :webpacker do asset_host = ActionController::Base.helpers.compute_asset_host env = { "NODE_ENV" => Webpacker.env, "ASSET_HOST" => asset_host }.freeze - _, stderr_str, status = Open3.capture3(env, "./bin/webpack") + stdout_str, stderr_str, status = Open3.capture3(env, "./bin/webpack") if status.success? - puts "[Webpacker] Compiled digests for all packs in #{Webpacker::Configuration.entry_path}:" + new_line - puts JSON.parse(File.read(Webpacker::Configuration.manifest_path)) + $stdout.puts "\e[32m[Webpacker] Compiled digests for all packs in #{Webpacker::Configuration.entry_path}:\e[0m" + new_line + $stdout.puts "\e[32m#{JSON.parse(File.read(Webpacker::Configuration.manifest_path))}\e[0m" else - $stderr.puts "[Webpacker] [FAIL]" + new_line - $stderr.puts stderr_str + $stdout.puts "[Webpacker] Compilation Failed" + new_line + $stdout.puts "\e[31m#{stdout_str}\e[0m" + new_line + $stderr.puts "\e[31m#{stderr_str}\e[0m" exit! end end From 6cc0600558676e4ec2566c79039c1456086a279e Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Mon, 22 May 2017 17:05:26 +0100 Subject: [PATCH 26/27] Use puts --- lib/tasks/webpacker/compile.rake | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/tasks/webpacker/compile.rake b/lib/tasks/webpacker/compile.rake index fb3a8bb70..665748d5b 100644 --- a/lib/tasks/webpacker/compile.rake +++ b/lib/tasks/webpacker/compile.rake @@ -5,8 +5,8 @@ require "webpacker/configuration" namespace :webpacker do desc "Compile javascript packs using webpack for production with digests" task compile: ["webpacker:verify_install", :environment] do - new_line = "\n\n" - puts "[Webpacker] Compiling assets 🎉" + new_line + puts "[Webpacker] Compiling assets 🎉" + puts asset_host = ActionController::Base.helpers.compute_asset_host env = { "NODE_ENV" => Webpacker.env, "ASSET_HOST" => asset_host }.freeze @@ -14,11 +14,13 @@ namespace :webpacker do stdout_str, stderr_str, status = Open3.capture3(env, "./bin/webpack") if status.success? - $stdout.puts "\e[32m[Webpacker] Compiled digests for all packs in #{Webpacker::Configuration.entry_path}:\e[0m" + new_line + $stdout.puts "\e[32m[Webpacker] Compiled digests for all packs in #{Webpacker::Configuration.entry_path}:\e[0m" + puts $stdout.puts "\e[32m#{JSON.parse(File.read(Webpacker::Configuration.manifest_path))}\e[0m" else - $stdout.puts "[Webpacker] Compilation Failed" + new_line - $stdout.puts "\e[31m#{stdout_str}\e[0m" + new_line + $stdout.puts "[Webpacker] Compilation Failed" + puts + $stdout.puts "\e[31m#{stdout_str}\e[0m" $stderr.puts "\e[31m#{stderr_str}\e[0m" exit! end From 57e7ecfa83f26a834f1a8365b5851a96eafec966 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Mon, 22 May 2017 17:06:28 +0100 Subject: [PATCH 27/27] Remove extra puts --- lib/tasks/webpacker/compile.rake | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/tasks/webpacker/compile.rake b/lib/tasks/webpacker/compile.rake index 665748d5b..0e04d51b3 100644 --- a/lib/tasks/webpacker/compile.rake +++ b/lib/tasks/webpacker/compile.rake @@ -6,7 +6,6 @@ namespace :webpacker do desc "Compile javascript packs using webpack for production with digests" task compile: ["webpacker:verify_install", :environment] do puts "[Webpacker] Compiling assets 🎉" - puts asset_host = ActionController::Base.helpers.compute_asset_host env = { "NODE_ENV" => Webpacker.env, "ASSET_HOST" => asset_host }.freeze @@ -15,11 +14,9 @@ namespace :webpacker do if status.success? $stdout.puts "\e[32m[Webpacker] Compiled digests for all packs in #{Webpacker::Configuration.entry_path}:\e[0m" - puts $stdout.puts "\e[32m#{JSON.parse(File.read(Webpacker::Configuration.manifest_path))}\e[0m" else $stdout.puts "[Webpacker] Compilation Failed" - puts $stdout.puts "\e[31m#{stdout_str}\e[0m" $stderr.puts "\e[31m#{stderr_str}\e[0m" exit!