【发布时间】:2018-02-05 19:30:09
【问题描述】:
我使用 create-react-app 创建了一个 react 应用程序,一切正常,只是我不知道如何加载 css/stylus 文件。
在我之前没有使用 create-react-app 创建的 react 项目中,我使用了 webpack.config,但现在我不知道在哪里包含该文件以及如何使用它。
这是我的文件夹结构:
.
+--client
| +--node_modules
| +--public
| +--src
| +--package.json
+--server
| +--node_modules
| +--src
| +--.babelrc
| +--package.json
这是我之前的webpack.config.dev.js文件:
import path from 'path';
import webpack from 'webpack';
export default {
entry: [
'webpack-hot-middleware/client?reload=true',
path.join(__dirname, '/client/index.js')
],
output: {
filename: 'bundle.js',
path: '/',
publicPath: '/'
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.HotModuleReplacementPlugin()
],
module: {
rules: [
{
test: /\.js$/,
include: path.join(__dirname, 'client'),
loader: 'babel-loader',
},
{
test: /\.styl$/,
use: [
'style-loader',
'css-loader',
{
loader: 'stylus-loader',
},
],
},
{
test: /\.css?$/,
use: [
'style-loader',
{
loader: 'css-loader',
},
],
},
],
},
resolve: {
extensions: [ '.js', '.styl' ]
}
}
如果我需要提供更多信息,请告诉我。
【问题讨论】:
标签: css node.js reactjs webpack