ruby-on-rails - Rails 6 webpack不加载样式表+引导程序?
问题描述
我已经在 Rails 6 中启动了一个项目,并且遵循了指南,我采用了带有 HTML 和 CSS 的 Bootstrap 模板,但是在加载视图时它没有显示引导程序或自定义 scss。
Bootstrap 安装了纱线,我在 javascripts / stylesheets / _home.scss 中有 css,如果我将样式放在普通视图中,如果它检测到它,但是将它放在包中并没有为我加载它,有人知道为什么它可以是 ?
javascript/packs/application.js
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
import 'bootstrap'
import '../stylesheets/application'
import '@fortawesome/fontawesome-free/js/all'
javascript/样式表/application.scss
@import "~bootstrap/scss/bootstrap.scss";
@import "home";
@import "@fortawesome/fontawesome-free";
webpack/environment.js
const { environment } = require('@rails/webpacker');
const webpack = require('webpack');
environment.plugins.append("Provide", new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
Popper: ['popper.js', 'default']
}));
environment.config.set('resolve.alias', {jquery: 'jquery/src/jquery'});
module.exports = environment;
webpacker.yml
# 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: []
# 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:
- .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
包.json
{
"name": "callcenter",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-free": "^5.13.1",
"@rails/actioncable": "^6.0.0",
"@rails/activestorage": "^6.0.0",
"@rails/ujs": "^6.0.0",
"@rails/webpacker": "4.2.2",
"bootstrap": "^4.5.0",
"jquery": "^3.5.1",
"popper.js": "^1.16.1",
"turbolinks": "^5.2.0"
},
"version": "0.1.0",
"devDependencies": {
"webpack-dev-server": "^3.11.0"
}
}
在此先感谢您的帮助^^
解决方案
推荐阅读
- url - IIS 8 Url 重写为忽略目录
- python - Django中未知最大长度的最佳实践?
- angular - 如何在 mat-tab 中导航不同的子组件?(不在主插座中)
- bash - 脚本修改只备份1个数据库
- java - 无法启动 bean 'stompBrokerRelayMessageHandler';嵌套异常是 java.lang.NoClassDefFoundError: io/netty/util/concurrent/EventExecutor
- momentjs - 如何使用时刻时区将 localTimeString 转换为 utcTimeString 并返回到 localTimeString
- php - 如何对某个目录中的目录和文件进行排序?
- glsl - 四元数除法和双曲正切 tanh
- php - 在 Wordpress 中“即时”编辑帖子
- javascript - 如何有 2 个带有专有元素的选择输入?