-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure webpack pipeline and move assets
- Loading branch information
Showing
34 changed files
with
4,443 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,5 @@ | |
!/log/.keep | ||
/tmp | ||
/spec/examples.txt | ||
/public/assets | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ AllCops: | |
- 'vendor/**' | ||
- 'db/schema.rb' | ||
- 'bin/**' | ||
- 'node_modules' | ||
TargetRubyVersion: 2.4 | ||
|
||
Rails: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function fn() { | ||
console.log('Testing') | ||
// abc | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', fn, false) |
16 changes: 0 additions & 16 deletions
16
app/assets/stylesheets/application.css.sass → app/assets/main.sass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint no-console:0 */ | ||
// This file is automatically compiled by Webpack, along with any other files | ||
// present in this directory. You're encouraged to place your actual application logic in | ||
// a relevant structure within app/javascript and only use these pack files to reference | ||
// that code so it'll be compiled. | ||
// | ||
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate | ||
// layout file, like app/views/layouts/application.html.erb | ||
|
||
console.log('Hello World from Webpacker') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env ruby | ||
$stdout.sync = true | ||
|
||
require "shellwords" | ||
require "yaml" | ||
|
||
ENV["RAILS_ENV"] ||= "development" | ||
RAILS_ENV = ENV["RAILS_ENV"] | ||
|
||
ENV["NODE_ENV"] ||= RAILS_ENV | ||
NODE_ENV = ENV["NODE_ENV"] | ||
|
||
APP_PATH = File.expand_path("../", __dir__) | ||
CONFIG_PATH = File.join(APP_PATH, "config/webpack/paths.yml") | ||
DEV_SERVER_CONFIG_PATH = File.join(APP_PATH, "config/webpack/development.server.yml") | ||
|
||
begin | ||
paths = YAML.load(File.read(CONFIG_PATH))[NODE_ENV] | ||
dev_server = YAML.load(File.read(DEV_SERVER_CONFIG_PATH))[NODE_ENV] | ||
|
||
NODE_MODULES_PATH = File.join(APP_PATH.shellescape, paths["node_modules"]) | ||
WEBPACK_CONFIG_PATH = File.join(APP_PATH.shellescape, paths["config"]) | ||
|
||
if NODE_ENV == "development" && dev_server["enabled"] | ||
$stderr.puts "Warning: webpack-dev-server is currently enabled in #{DEV_SERVER_CONFIG_PATH}. " \ | ||
"Disable to serve assets directly from public/packs directory" | ||
end | ||
rescue Errno::ENOENT, NoMethodError | ||
puts "Configuration not found in config/webpack/paths.yml or config/webpack/development.server.yml." | ||
puts "Please run bundle exec rails webpacker:install to install webpacker" | ||
exit! | ||
end | ||
|
||
WEBPACK_BIN = "#{NODE_MODULES_PATH}/.bin/webpack" | ||
WEBPACK_CONFIG = "#{WEBPACK_CONFIG_PATH}/#{NODE_ENV}.js" | ||
|
||
Dir.chdir(APP_PATH) do | ||
exec "NODE_ENV=#{NODE_ENV} NODE_PATH=#{NODE_MODULES_PATH} #{WEBPACK_BIN} " \ | ||
"--config #{WEBPACK_CONFIG} #{ARGV.join(" ")}" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env ruby | ||
$stdout.sync = true | ||
|
||
require "shellwords" | ||
require "yaml" | ||
|
||
ENV["RAILS_ENV"] ||= "development" | ||
RAILS_ENV = ENV["RAILS_ENV"] | ||
|
||
ENV["NODE_ENV"] ||= RAILS_ENV | ||
NODE_ENV = ENV["NODE_ENV"] | ||
|
||
APP_PATH = File.expand_path("../", __dir__) | ||
CONFIG_PATH = File.join(APP_PATH, "config/webpack/paths.yml") | ||
|
||
begin | ||
paths = YAML.load(File.read(CONFIG_PATH))[NODE_ENV] | ||
|
||
NODE_MODULES_PATH = File.join(APP_PATH.shellescape, paths["node_modules"]) | ||
WEBPACK_CONFIG_PATH = File.join(APP_PATH.shellescape, paths["config"]) | ||
|
||
WEBPACK_BIN = "#{NODE_MODULES_PATH}/.bin/webpack-dev-server" | ||
DEV_SERVER_CONFIG = "#{WEBPACK_CONFIG_PATH}/development.js" | ||
rescue Errno::ENOENT, NoMethodError | ||
puts "Configuration not found in config/webpacker/paths.yml." | ||
puts "Please run bundle exec rails webpacker:install to install webpacker" | ||
exit! | ||
end | ||
|
||
Dir.chdir(APP_PATH) do | ||
exec "NODE_PATH=#{NODE_MODULES_PATH} #{WEBPACK_BIN} --progress --color " \ | ||
"--config #{DEV_SERVER_CONFIG}" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env ruby | ||
|
||
ENV['RAILS_ENV'] ||= 'development' | ||
ENV['NODE_ENV'] ||= ENV['RAILS_ENV'] | ||
|
||
BIN_PATH = File.expand_path('.', __dir__) | ||
|
||
Dir.chdir(BIN_PATH) do | ||
exec "./webpack --watch --progress --color #{ARGV.join(" ")}" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env ruby | ||
VENDOR_PATH = File.expand_path('..', __dir__) | ||
Dir.chdir(VENDOR_PATH) do | ||
begin | ||
exec "yarnpkg #{ARGV.join(" ")}" | ||
rescue Errno::ENOENT | ||
$stderr.puts "Yarn executable was not detected in the system." | ||
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" | ||
exit 1 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
Rails.application.routes.draw do | ||
resources :traces, only: %i[index show] | ||
resources :transactions, only: %i[index show] | ||
resources :traces, only: %i(index show) | ||
resources :transactions, only: %i(index show) | ||
|
||
root to: 'root#index' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Note: You must restart bin/webpack-watcher for changes to take effect | ||
/* eslint global-require: 0 */ | ||
/* eslint import/no-dynamic-require: 0 */ | ||
|
||
const webpack = require('webpack') | ||
const autoprefixer = require('autoprefixer') | ||
const csswring = require('csswring') | ||
|
||
const ExtractTextPlugin = require('extract-text-webpack-plugin') | ||
const ManifestPlugin = require('webpack-manifest-plugin') | ||
|
||
const { resolve } = require('path') | ||
const { env, paths, publicPath, loadersDir } = require('./configuration.js') | ||
|
||
console.log(publicPath) | ||
|
||
module.exports = { | ||
entry: { | ||
main: ['main.js', 'main.sass'] | ||
}, | ||
|
||
output: { | ||
path: resolve(paths.output), | ||
filename: '[name].js', | ||
chunkFilename: '[name].[id].[chunkhash].js', | ||
publicPath | ||
}, | ||
|
||
module: { | ||
rules: [{ | ||
test: /\.(jpg|jpeg|png|gif|svg|eot|ttf|woff|woff2)$/i, | ||
use: [{ | ||
loader: 'file-loader', | ||
options: { name: (env.NODE_ENV === 'production' ? '[name]-[hash].[ext]' : '[name].[ext]') } | ||
}] | ||
}, { | ||
test: /\.(scss|sass|css)$/i, | ||
use: ExtractTextPlugin.extract({ | ||
use: [{ | ||
loader: 'css-loader', | ||
options: { | ||
minimize: env.NODE_ENV === 'production', | ||
importLoaders: 2 | ||
} | ||
}, { | ||
loader: 'postcss-loader', | ||
options: { | ||
plugins: () => [ | ||
require('autoprefixer'), | ||
require('csswring') | ||
] | ||
} | ||
}, { | ||
loader: 'sass-loader', | ||
options: { | ||
includePaths: [ | ||
require('bourbon').includePaths | ||
] | ||
} | ||
}] | ||
}) | ||
}, { | ||
test: /\.(js)$/i, | ||
use: [{ | ||
loader: 'babel-loader', | ||
options: { | ||
presets: ['env'] | ||
} | ||
}] | ||
}] | ||
}, | ||
|
||
plugins: [ | ||
new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))), | ||
new ExtractTextPlugin(env.NODE_ENV === 'production' ? '[name]-[hash].css' : '[name].css'), | ||
new ManifestPlugin({ fileName: paths.manifest, writeToFileEmit: true, publicPath }), | ||
new webpack.optimize.UglifyJsPlugin({sourceMap: true}) | ||
], | ||
|
||
resolve: { | ||
extensions: [ | ||
'.coffee', '.js', '.sass', '.scss', '.css', '.png', '.svg', '.jpg' | ||
], | ||
modules: [ | ||
resolve(paths.source), | ||
resolve(paths.node_modules) | ||
] | ||
}, | ||
|
||
resolveLoader: { | ||
modules: [paths.node_modules] | ||
} | ||
} |
Oops, something went wrong.