react-bootstrap 使用 webpack
react-bootstrap using webpack
我正在尝试将 react-bootstrap 与 web pack 一起使用。我能够在页面上获得 bootstrap <Button>
,但没有附加样式?
我已经安装:
"devDependencies": {
"babel-core": "^5.1.11",
"babel-loader": "^5.0.0",
"css-loader": "^0.12.1",
"react-hot-loader": "^1.2.2",
"react-router": "^0.13.3",
"webpack": "^1.7.2",
"webpack-dev-server": "^1.7.0"
},
"dependencies": {
"bootstrap": "^3.3.4",
"react": "^0.13.0",
"react-bootstrap": "^0.22.6",
"whatwg-fetch": "^0.8.1"
}
}
加载程序在 webpack.config.js
module: {
loaders: [
{ test: /\.jsx?$/, loaders: ['react-hot', 'babel'], include: path.join(__dirname, 'app') },
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.png$/, loader: "url-loader?limit=100000" },
{ test: /\.jpg$/, loader: "file-loader" }
]
}
react-bootstrap 不包含 bootstrap 样式。
正如他们在 Getting Started 页面上所说:
Because React-Bootstrap doesn't depend on a very precise version of Bootstrap, we don't ship with any included CSS. However, some stylesheet is required to use these components.
您应该从 bootstrap/dist/css/bootstrap.css
导入样式。由于您已经为 css 文件设置了加载程序并且依赖于 bootstrap,它就像
一样简单
require('bootstrap/dist/css/bootstrap.css');
或
import "bootstrap/dist/css/bootstrap.css";
我正在尝试将 react-bootstrap 与 web pack 一起使用。我能够在页面上获得 bootstrap <Button>
,但没有附加样式?
我已经安装:
"devDependencies": {
"babel-core": "^5.1.11",
"babel-loader": "^5.0.0",
"css-loader": "^0.12.1",
"react-hot-loader": "^1.2.2",
"react-router": "^0.13.3",
"webpack": "^1.7.2",
"webpack-dev-server": "^1.7.0"
},
"dependencies": {
"bootstrap": "^3.3.4",
"react": "^0.13.0",
"react-bootstrap": "^0.22.6",
"whatwg-fetch": "^0.8.1"
}
}
加载程序在 webpack.config.js
module: {
loaders: [
{ test: /\.jsx?$/, loaders: ['react-hot', 'babel'], include: path.join(__dirname, 'app') },
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.png$/, loader: "url-loader?limit=100000" },
{ test: /\.jpg$/, loader: "file-loader" }
]
}
react-bootstrap 不包含 bootstrap 样式。
正如他们在 Getting Started 页面上所说:
Because React-Bootstrap doesn't depend on a very precise version of Bootstrap, we don't ship with any included CSS. However, some stylesheet is required to use these components.
您应该从 bootstrap/dist/css/bootstrap.css
导入样式。由于您已经为 css 文件设置了加载程序并且依赖于 bootstrap,它就像
require('bootstrap/dist/css/bootstrap.css');
或
import "bootstrap/dist/css/bootstrap.css";