chore(build): use vitejs
This commit is contained in:
parent
070a89db11
commit
ea18c2b9ba
37 changed files with 1119 additions and 4437 deletions
|
@ -3,9 +3,6 @@ require "active_support/core_ext/integer/time"
|
|||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# Verifies that versions and hashed value of the package contents in the project's package.json
|
||||
config.webpacker.check_yarn_integrity = true
|
||||
|
||||
# In the development environment your application's code is reloaded any time
|
||||
# it changes. This slows down response time but is perfect for development
|
||||
# since you don't have to restart the web server when you make code changes.
|
||||
|
|
|
@ -4,9 +4,6 @@ require Rails.root.join("app/lib/balancer_delivery_method")
|
|||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# Verifies that versions and hashed value of the package contents in the project's package.json
|
||||
config.webpacker.check_yarn_integrity = false
|
||||
|
||||
# Code is not reloaded between requests.
|
||||
config.cache_classes = true
|
||||
|
||||
|
|
|
@ -44,6 +44,10 @@ Rails.application.config.content_security_policy do |policy|
|
|||
# Allow LiveReload requests
|
||||
policy.connect_src(*policy.connect_src, "ws://localhost:3035", "http://localhost:3035")
|
||||
|
||||
# Allow Vite.js
|
||||
policy.connect_src(*policy.connect_src, "ws://#{ViteRuby.config.host_with_port}")
|
||||
policy.script_src(*policy.script_src, :unsafe_eval, "http://#{ViteRuby.config.host_with_port}")
|
||||
|
||||
# CSP are not enforced in development (see content_security_policy_report_only in development.rb)
|
||||
# However we notify a random local URL, to see breakage in the DevTools when adding a new external resource.
|
||||
policy.report_uri "http://#{ENV.fetch('APP_HOST')}/csp/"
|
||||
|
@ -52,7 +56,7 @@ Rails.application.config.content_security_policy do |policy|
|
|||
# Disallow all connections to external domains during tests
|
||||
policy.img_src(:self, :data, :blob)
|
||||
policy.script_src(:self, :unsafe_eval, :unsafe_inline, :blob)
|
||||
policy.style_src(:self)
|
||||
policy.style_src(:self, :unsafe_inline)
|
||||
policy.connect_src(:self)
|
||||
policy.frame_src(:self)
|
||||
policy.default_src(:self, :data, :blob)
|
||||
|
|
16
config/vite.json
Normal file
16
config/vite.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"all": {
|
||||
"sourceCodeDir": "app/javascript",
|
||||
"watchAdditionalPaths": []
|
||||
},
|
||||
"development": {
|
||||
"autoBuild": true,
|
||||
"publicOutputDir": "vite-dev",
|
||||
"port": 3036
|
||||
},
|
||||
"test": {
|
||||
"autoBuild": true,
|
||||
"publicOutputDir": "vite-test",
|
||||
"port": 3037
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
const environment = require('./environment');
|
||||
|
||||
module.exports = environment.toWebpackConfig();
|
|
@ -1,34 +0,0 @@
|
|||
const path = require('path');
|
||||
const { environment } = require('@rails/webpacker');
|
||||
|
||||
const resolve = {
|
||||
alias: {
|
||||
'@utils': path.resolve(__dirname, '..', '..', 'app/javascript/shared/utils')
|
||||
}
|
||||
};
|
||||
|
||||
environment.splitChunks();
|
||||
environment.config.merge({ resolve });
|
||||
|
||||
// Excluding node_modules From Being Transpiled By Babel-Loader
|
||||
// One change to take into consideration,
|
||||
// is that Webpacker 4 transpiles the node_modules folder with the babel-loader.
|
||||
// This folder used to be ignored by Webpacker 3.
|
||||
// The new behavior helps in case some library contains ES6 code, but in some cases it can lead to issues.
|
||||
// To avoid running babel-loader in the node_modules folder, replicating the same behavior as Webpacker 3,
|
||||
// we added the following code:
|
||||
|
||||
const nodeModulesLoader = environment.loaders.get('nodeModules');
|
||||
if (!Array.isArray(nodeModulesLoader.exclude)) {
|
||||
nodeModulesLoader.exclude =
|
||||
nodeModulesLoader.exclude == null ? [] : [nodeModulesLoader.exclude];
|
||||
}
|
||||
nodeModulesLoader.exclude.push(
|
||||
path.resolve(__dirname, '..', '..', 'node_modules/maplibre-gl')
|
||||
);
|
||||
|
||||
// Uncoment next lines to run webpack-bundle-analyzer
|
||||
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||
// environment.plugins.append('BundleAnalyzer', new BundleAnalyzerPlugin());
|
||||
|
||||
module.exports = environment;
|
|
@ -1,5 +0,0 @@
|
|||
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
||||
|
||||
const environment = require('./environment');
|
||||
|
||||
module.exports = environment.toWebpackConfig();
|
|
@ -1,5 +0,0 @@
|
|||
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
const environment = require('./environment');
|
||||
|
||||
module.exports = environment.toWebpackConfig();
|
|
@ -1,95 +0,0 @@
|
|||
# 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
|
||||
webpack_compile_output: false
|
||||
|
||||
# Additional paths webpack should lookup modules
|
||||
# ['app/assets', 'engine/foo/app/assets']
|
||||
additional_paths: []
|
||||
|
||||
# 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:
|
||||
- .tsx
|
||||
- .ts
|
||||
- .mjs
|
||||
- .js
|
||||
- .jsx
|
||||
- .sass
|
||||
- .scss
|
||||
- .css
|
||||
- .module.sass
|
||||
- .module.scss
|
||||
- .module.css
|
||||
- .png
|
||||
- .svg
|
||||
- .gif
|
||||
- .jpeg
|
||||
- .jpg
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
compile: 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
|
Loading…
Add table
Add a link
Reference in a new issue