mirror of
https://github.com/moebooru/moebooru
synced 2025-08-22 09:57:31 +00:00
Add webpacker
This commit is contained in:
parent
12c81d7395
commit
43b7c14f07
1
.browserslistrc
Normal file
1
.browserslistrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
defaults
|
7
.gitignore
vendored
7
.gitignore
vendored
@ -12,3 +12,10 @@
|
|||||||
/public/sitemap*.xml.gz
|
/public/sitemap*.xml.gz
|
||||||
/tmp
|
/tmp
|
||||||
/vendor/bundle
|
/vendor/bundle
|
||||||
|
|
||||||
|
/public/packs
|
||||||
|
/public/packs-test
|
||||||
|
/node_modules
|
||||||
|
/yarn-error.log
|
||||||
|
yarn-debug.log*
|
||||||
|
.yarn-integrity
|
||||||
|
1
Gemfile
1
Gemfile
@ -2,6 +2,7 @@ source "https://rubygems.org"
|
|||||||
|
|
||||||
gem "rails", "~> 6.0.0"
|
gem "rails", "~> 6.0.0"
|
||||||
|
|
||||||
|
gem "webpacker"
|
||||||
gem "coffee-rails"
|
gem "coffee-rails"
|
||||||
gem "jquery-rails"
|
gem "jquery-rails"
|
||||||
gem "jquery-ui-rails"
|
gem "jquery-ui-rails"
|
||||||
|
@ -149,6 +149,8 @@ GEM
|
|||||||
rack (2.2.2)
|
rack (2.2.2)
|
||||||
rack-mini-profiler (2.0.1)
|
rack-mini-profiler (2.0.1)
|
||||||
rack (>= 1.2.0)
|
rack (>= 1.2.0)
|
||||||
|
rack-proxy (0.6.5)
|
||||||
|
rack
|
||||||
rack-test (1.1.0)
|
rack-test (1.1.0)
|
||||||
rack (>= 1.0, < 3)
|
rack (>= 1.0, < 3)
|
||||||
rails (6.0.2.2)
|
rails (6.0.2.2)
|
||||||
@ -206,6 +208,7 @@ GEM
|
|||||||
sprockets (> 3.0)
|
sprockets (> 3.0)
|
||||||
sprockets-rails
|
sprockets-rails
|
||||||
tilt
|
tilt
|
||||||
|
semantic_range (2.3.0)
|
||||||
sitemap_generator (6.1.0)
|
sitemap_generator (6.1.0)
|
||||||
builder (~> 3.0)
|
builder (~> 3.0)
|
||||||
spoon (0.0.6)
|
spoon (0.0.6)
|
||||||
@ -231,6 +234,11 @@ GEM
|
|||||||
unicorn-worker-killer (0.4.4)
|
unicorn-worker-killer (0.4.4)
|
||||||
get_process_mem (~> 0)
|
get_process_mem (~> 0)
|
||||||
unicorn (>= 4, < 6)
|
unicorn (>= 4, < 6)
|
||||||
|
webpacker (5.0.1)
|
||||||
|
activesupport (>= 5.2)
|
||||||
|
rack-proxy (>= 0.6.1)
|
||||||
|
railties (>= 5.2)
|
||||||
|
semantic_range (>= 2.3.0)
|
||||||
websocket-driver (0.7.1)
|
websocket-driver (0.7.1)
|
||||||
websocket-extensions (>= 0.1.0)
|
websocket-extensions (>= 0.1.0)
|
||||||
websocket-driver (0.7.1-java)
|
websocket-driver (0.7.1-java)
|
||||||
@ -282,6 +290,7 @@ DEPENDENCIES
|
|||||||
uglifier
|
uglifier
|
||||||
unicorn
|
unicorn
|
||||||
unicorn-worker-killer
|
unicorn-worker-killer
|
||||||
|
webpacker
|
||||||
will-paginate-i18n
|
will-paginate-i18n
|
||||||
will_paginate
|
will_paginate
|
||||||
|
|
||||||
|
72
babel.config.js
Normal file
72
babel.config.js
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
module.exports = function(api) {
|
||||||
|
var validEnv = ['development', 'test', 'production']
|
||||||
|
var currentEnv = api.env()
|
||||||
|
var isDevelopmentEnv = api.env('development')
|
||||||
|
var isProductionEnv = api.env('production')
|
||||||
|
var isTestEnv = api.env('test')
|
||||||
|
|
||||||
|
if (!validEnv.includes(currentEnv)) {
|
||||||
|
throw new Error(
|
||||||
|
'Please specify a valid `NODE_ENV` or ' +
|
||||||
|
'`BABEL_ENV` environment variables. Valid values are "development", ' +
|
||||||
|
'"test", and "production". Instead, received: ' +
|
||||||
|
JSON.stringify(currentEnv) +
|
||||||
|
'.'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
presets: [
|
||||||
|
isTestEnv && [
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
targets: {
|
||||||
|
node: 'current'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
(isProductionEnv || isDevelopmentEnv) && [
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
forceAllTransforms: true,
|
||||||
|
useBuiltIns: 'entry',
|
||||||
|
corejs: 3,
|
||||||
|
modules: false,
|
||||||
|
exclude: ['transform-typeof-symbol']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
].filter(Boolean),
|
||||||
|
plugins: [
|
||||||
|
'babel-plugin-macros',
|
||||||
|
'@babel/plugin-syntax-dynamic-import',
|
||||||
|
isTestEnv && 'babel-plugin-dynamic-import-node',
|
||||||
|
'@babel/plugin-transform-destructuring',
|
||||||
|
[
|
||||||
|
'@babel/plugin-proposal-class-properties',
|
||||||
|
{
|
||||||
|
loose: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'@babel/plugin-proposal-object-rest-spread',
|
||||||
|
{
|
||||||
|
useBuiltIns: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'@babel/plugin-transform-runtime',
|
||||||
|
{
|
||||||
|
helpers: false,
|
||||||
|
regenerator: true,
|
||||||
|
corejs: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'@babel/plugin-transform-regenerator',
|
||||||
|
{
|
||||||
|
async: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
].filter(Boolean)
|
||||||
|
}
|
||||||
|
}
|
18
bin/webpack
Executable file
18
bin/webpack
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
|
||||||
|
ENV["NODE_ENV"] ||= "development"
|
||||||
|
|
||||||
|
require "pathname"
|
||||||
|
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
||||||
|
Pathname.new(__FILE__).realpath)
|
||||||
|
|
||||||
|
require "bundler/setup"
|
||||||
|
|
||||||
|
require "webpacker"
|
||||||
|
require "webpacker/webpack_runner"
|
||||||
|
|
||||||
|
APP_ROOT = File.expand_path("..", __dir__)
|
||||||
|
Dir.chdir(APP_ROOT) do
|
||||||
|
Webpacker::WebpackRunner.run(ARGV)
|
||||||
|
end
|
18
bin/webpack-dev-server
Executable file
18
bin/webpack-dev-server
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
|
||||||
|
ENV["NODE_ENV"] ||= "development"
|
||||||
|
|
||||||
|
require "pathname"
|
||||||
|
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
||||||
|
Pathname.new(__FILE__).realpath)
|
||||||
|
|
||||||
|
require "bundler/setup"
|
||||||
|
|
||||||
|
require "webpacker"
|
||||||
|
require "webpacker/dev_server_runner"
|
||||||
|
|
||||||
|
APP_ROOT = File.expand_path("..", __dir__)
|
||||||
|
Dir.chdir(APP_ROOT) do
|
||||||
|
Webpacker::DevServerRunner.run(ARGV)
|
||||||
|
end
|
@ -2,6 +2,7 @@ require_relative 'boot'
|
|||||||
|
|
||||||
# To allow setting environment variable ZP_DATABASE_URL instead of DATABASE_URL.
|
# To allow setting environment variable ZP_DATABASE_URL instead of DATABASE_URL.
|
||||||
ENV['DATABASE_URL'] = ENV['MB_DATABASE_URL'] if ENV['MB_DATABASE_URL']
|
ENV['DATABASE_URL'] = ENV['MB_DATABASE_URL'] if ENV['MB_DATABASE_URL']
|
||||||
|
ENV['NODE_ENV'] = ENV['RAILS_ENV']
|
||||||
|
|
||||||
require 'rails/all'
|
require 'rails/all'
|
||||||
|
|
||||||
|
5
config/webpack/development.js
Normal file
5
config/webpack/development.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
|
||||||
|
|
||||||
|
const environment = require('./environment')
|
||||||
|
|
||||||
|
module.exports = environment.toWebpackConfig()
|
7
config/webpack/environment.js
Normal file
7
config/webpack/environment.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
const { environment } = require('@rails/webpacker')
|
||||||
|
const coffee = require('./loaders/coffee')
|
||||||
|
const erb = require('./loaders/erb')
|
||||||
|
|
||||||
|
environment.loaders.prepend('erb', erb)
|
||||||
|
environment.loaders.prepend('coffee', coffee)
|
||||||
|
module.exports = environment
|
6
config/webpack/loaders/coffee.js
Normal file
6
config/webpack/loaders/coffee.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module.exports = {
|
||||||
|
test: /\.coffee(\.erb)?$/,
|
||||||
|
use: [{
|
||||||
|
loader: 'coffee-loader'
|
||||||
|
}]
|
||||||
|
}
|
11
config/webpack/loaders/erb.js
Normal file
11
config/webpack/loaders/erb.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
module.exports = {
|
||||||
|
test: /\.erb$/,
|
||||||
|
enforce: 'pre',
|
||||||
|
exclude: /node_modules/,
|
||||||
|
use: [{
|
||||||
|
loader: 'rails-erb-loader',
|
||||||
|
options: {
|
||||||
|
runner: (/^win/.test(process.platform) ? 'ruby ' : '') + 'bin/rails runner'
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
5
config/webpack/production.js
Normal file
5
config/webpack/production.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
||||||
|
|
||||||
|
const environment = require('./environment')
|
||||||
|
|
||||||
|
module.exports = environment.toWebpackConfig()
|
5
config/webpack/test.js
Normal file
5
config/webpack/test.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
|
||||||
|
|
||||||
|
const environment = require('./environment')
|
||||||
|
|
||||||
|
module.exports = environment.toWebpackConfig()
|
100
config/webpacker.yml
Normal file
100
config/webpacker.yml
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
# Note: You must restart bin/webpack-dev-server for changes to take effect
|
||||||
|
|
||||||
|
default: &default
|
||||||
|
source_path: app/javascript
|
||||||
|
source_entry_path: packs
|
||||||
|
public_root_path: public
|
||||||
|
public_output_path: packs
|
||||||
|
cache_path: tmp/cache/webpacker
|
||||||
|
check_yarn_integrity: false
|
||||||
|
webpack_compile_output: true
|
||||||
|
|
||||||
|
# Additional paths webpack should lookup modules
|
||||||
|
# ['app/assets', 'engine/foo/app/assets']
|
||||||
|
resolved_paths: ['lib/assets/javascripts']
|
||||||
|
|
||||||
|
|
||||||
|
# Reload manifest.json on all requests so we reload latest compiled packs
|
||||||
|
cache_manifest: false
|
||||||
|
|
||||||
|
# Extract and emit a css file
|
||||||
|
extract_css: false
|
||||||
|
|
||||||
|
static_assets_extensions:
|
||||||
|
- .jpg
|
||||||
|
- .jpeg
|
||||||
|
- .png
|
||||||
|
- .gif
|
||||||
|
- .tiff
|
||||||
|
- .ico
|
||||||
|
- .svg
|
||||||
|
- .eot
|
||||||
|
- .otf
|
||||||
|
- .ttf
|
||||||
|
- .woff
|
||||||
|
- .woff2
|
||||||
|
|
||||||
|
extensions:
|
||||||
|
- .coffee
|
||||||
|
- .erb
|
||||||
|
- .coffee.erb
|
||||||
|
- .mjs
|
||||||
|
- .js
|
||||||
|
- .sass
|
||||||
|
- .scss
|
||||||
|
- .css
|
||||||
|
- .module.sass
|
||||||
|
- .module.scss
|
||||||
|
- .module.css
|
||||||
|
- .png
|
||||||
|
- .svg
|
||||||
|
- .gif
|
||||||
|
- .jpeg
|
||||||
|
- .jpg
|
||||||
|
|
||||||
|
development:
|
||||||
|
<<: *default
|
||||||
|
compile: true
|
||||||
|
|
||||||
|
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
|
||||||
|
check_yarn_integrity: true
|
||||||
|
|
||||||
|
# Reference: https://webpack.js.org/configuration/dev-server/
|
||||||
|
dev_server:
|
||||||
|
https: false
|
||||||
|
host: localhost
|
||||||
|
port: 3035
|
||||||
|
public: localhost:3035
|
||||||
|
hmr: false
|
||||||
|
# Inline should be set to true if using HMR
|
||||||
|
inline: true
|
||||||
|
overlay: true
|
||||||
|
compress: true
|
||||||
|
disable_host_check: true
|
||||||
|
use_local_ip: false
|
||||||
|
quiet: false
|
||||||
|
pretty: false
|
||||||
|
headers:
|
||||||
|
'Access-Control-Allow-Origin': '*'
|
||||||
|
watch_options:
|
||||||
|
ignored: '**/node_modules/**'
|
||||||
|
|
||||||
|
|
||||||
|
test:
|
||||||
|
<<: *default
|
||||||
|
compile: true
|
||||||
|
|
||||||
|
# Compile test packs to a separate directory
|
||||||
|
public_output_path: packs-test
|
||||||
|
|
||||||
|
production:
|
||||||
|
<<: *default
|
||||||
|
|
||||||
|
# Production depends on precompilation of packs prior to booting for performance.
|
||||||
|
compile: false
|
||||||
|
|
||||||
|
# Extract and emit a css file
|
||||||
|
extract_css: true
|
||||||
|
|
||||||
|
# Cache manifest.json for performance
|
||||||
|
cache_manifest: true
|
11
package.json
Normal file
11
package.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"@rails/webpacker": "5.0.1",
|
||||||
|
"coffee-loader": "^0.9.0",
|
||||||
|
"coffeescript": "1.12.7",
|
||||||
|
"rails-erb-loader": "^5.5.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"webpack-dev-server": "^3.10.3"
|
||||||
|
}
|
||||||
|
}
|
12
postcss.config.js
Normal file
12
postcss.config.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
module.exports = {
|
||||||
|
plugins: [
|
||||||
|
require('postcss-import'),
|
||||||
|
require('postcss-flexbugs-fixes'),
|
||||||
|
require('postcss-preset-env')({
|
||||||
|
autoprefixer: {
|
||||||
|
flexbox: 'no-2009'
|
||||||
|
},
|
||||||
|
stage: 3
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user