-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
962 additions
and
80 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 |
---|---|---|
|
@@ -27,3 +27,5 @@ | |
|
||
# Carrierwave uploads | ||
/public/uploads | ||
/public/packs | ||
/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
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,9 @@ | ||
// 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env ruby | ||
|
||
RAILS_ENV = ENV['RAILS_ENV'] || 'development' | ||
NODE_ENV = ENV['NODE_ENV'] || RAILS_ENV | ||
|
||
APP_PATH = File.expand_path('../', __dir__) | ||
|
||
SET_NODE_PATH = "NODE_PATH=#{APP_PATH}/node_modules" | ||
WEBPACK_BIN = "./node_modules/webpack/bin/webpack.js" | ||
WEBPACK_CONFIG = "#{APP_PATH}/config/webpack/#{NODE_ENV}.js" | ||
|
||
Dir.chdir(APP_PATH) do | ||
exec "#{SET_NODE_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,22 @@ | ||
#!/usr/bin/env ruby | ||
|
||
RAILS_ENV = ENV['RAILS_ENV'] || 'development' | ||
NODE_ENV = ENV['NODE_ENV'] || RAILS_ENV | ||
|
||
APP_PATH = File.expand_path('../', __dir__) | ||
|
||
SET_NODE_PATH = "NODE_PATH=#{APP_PATH}/node_modules" | ||
WEBPACKER_BIN = "./node_modules/.bin/webpack-dev-server" | ||
WEBPACK_CONFIG = "#{APP_PATH}/config/webpack/#{NODE_ENV}.js" | ||
|
||
# Warn the user if the configuration is not set | ||
RAILS_ENV_CONFIG = File.join("config", "environments", "#{RAILS_ENV}.rb") | ||
|
||
# Look into the environment file for a non-commented variable declaration | ||
unless File.foreach(File.join(APP_PATH, RAILS_ENV_CONFIG)).detect { |line| line.match(/^\s*[^#]*config\.x\.webpacker\[\:dev_server_host\].*=/) } | ||
puts "Warning: if you want to use webpack-dev-server, you need to tell Webpacker to serve asset packs from it. Please set config.x.webpacker[:dev_server_host] in #{RAILS_ENV_CONFIG}.\n\n" | ||
end | ||
|
||
Dir.chdir(APP_PATH) do | ||
exec "#{SET_NODE_PATH} #{WEBPACKER_BIN} --config #{WEBPACK_CONFIG} --content-base #{APP_PATH}/public/packs #{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,7 @@ | ||
#!/usr/bin/env ruby | ||
|
||
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,10 @@ | ||
#!/usr/bin/env ruby | ||
VENDOR_PATH = File.expand_path('..', __dir__) | ||
Dir.chdir(VENDOR_PATH) do | ||
begin | ||
exec "yarnpkg #{ARGV.join(" ")}" | ||
rescue Errno::ENOENT | ||
puts "Yarn executable was not detected in the system." | ||
puts "Download Yarn at https://yarnpkg.com/en/docs/install" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Note: You must restart bin/webpack-watcher for changes to take effect | ||
|
||
var webpack = require('webpack') | ||
var merge = require('webpack-merge') | ||
|
||
var sharedConfig = require('./shared.js') | ||
|
||
module.exports = merge(sharedConfig.config, { | ||
devtool: 'sourcemap', | ||
|
||
stats: { | ||
errorDetails: true | ||
}, | ||
|
||
output: { | ||
pathinfo: true | ||
}, | ||
|
||
plugins: [ | ||
new webpack.LoaderOptionsPlugin({ | ||
debug: true | ||
}) | ||
] | ||
}) |
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,16 @@ | ||
// Note: You must restart bin/webpack-watcher for changes to take effect | ||
|
||
var webpack = require('webpack') | ||
var merge = require('webpack-merge') | ||
|
||
var sharedConfig = require('./shared.js') | ||
|
||
module.exports = merge(sharedConfig.config, { | ||
output: { filename: '[name]-[hash].js' }, | ||
|
||
plugins: [ | ||
new webpack.LoaderOptionsPlugin({ | ||
minimize: true | ||
}) | ||
] | ||
}) |
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,69 @@ | ||
// Note: You must restart bin/webpack-watcher for changes to take effect | ||
|
||
var webpack = require('webpack') | ||
var path = require('path') | ||
var process = require('process') | ||
var glob = require('glob') | ||
var extname = require('path-complete-extname') | ||
var distDir = process.env.WEBPACK_DIST_DIR | ||
|
||
if(distDir === undefined) { | ||
distDir = 'packs' | ||
} | ||
|
||
config = { | ||
entry: glob.sync(path.join('app', 'javascript', 'packs', '*.js*')).reduce( | ||
function(map, entry) { | ||
var basename = path.basename(entry, extname(entry)) | ||
map[basename] = path.resolve(entry) | ||
return map | ||
}, {} | ||
), | ||
|
||
output: { filename: '[name].js', path: path.resolve('public', distDir) }, | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js(.erb)?$/, | ||
exclude: /node_modules/, | ||
loader: 'babel-loader', | ||
options: { | ||
presets: [ | ||
[ 'latest', { 'es2015': { 'modules': false } } ] | ||
] | ||
} | ||
}, | ||
{ | ||
test: /.erb$/, | ||
enforce: 'pre', | ||
exclude: /node_modules/, | ||
loader: 'rails-erb-loader', | ||
options: { | ||
runner: 'DISABLE_SPRING=1 bin/rails runner' | ||
} | ||
}, | ||
] | ||
}, | ||
|
||
plugins: [ | ||
new webpack.EnvironmentPlugin(Object.keys(process.env)) | ||
], | ||
|
||
resolve: { | ||
extensions: [ '.js' ], | ||
modules: [ | ||
path.resolve('app/javascript'), | ||
path.resolve('node_modules') | ||
] | ||
}, | ||
|
||
resolveLoader: { | ||
modules: [ path.resolve('node_modules') ] | ||
} | ||
} | ||
|
||
module.exports = { | ||
distDir: distDir, | ||
config: config | ||
} |
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
Oops, something went wrong.