css - foundation-sites 包含在 webpack 中。不能使用样式

标签 css node.js reactjs webpack

我是整个 webpack 的新手,到目前为止,它是巫术!我正在努力为网站的运行奠定基础,但我不知道如何正确设置它。

网络包配置

var webpack = require('webpack');
var path = require('path');

var config = {
    entry: './src/client/app/index.jsx',
    output: {
        path: __dirname + '/src/client/public/',
        filename: 'bundle.js'
    },
    module: {
        loaders: [
            {
                test: /\.(js|jsx)$/,
                include: __dirname + '/src/client/app',
                exclude: /node_modules/,
                loader: 'babel-loader'
            },
            {
                test: /\.(css|scss)$/,
                loader: 'sass-loader'
            }
        ]
    }
};

module.exports = config;

master.scss

@import "foundation";

@include foundation-everything;

我的目录结构:

directory structure

Web 应用程序正常工作,但在呈现时:

import React from 'react';
import {render} from 'react-dom';

import './styles/navigation.scss';

export default class Navigation extends React.Component {
    render() {
        return (
            <div className="top-bar topbar-background">
                <div className="top-bar-left">
                    <ul className="menu">
                        <li className="menu-text">App</li>
                        <li><a href="/">Home</a></li>
                        <li><a href="/services">Services</a></li>
                    </ul>
                </div>
                <div className="top-bar-right">
                    <ul className="menu">
                        <li><a href="/login">Login/Register</a></li>
                        <li><a href="/terms">Terms</a></li>
                    </ul>
                </div>        
            </div>
        )
    }
}

我在传统的老式 HTML 中看到可怕的列表项。那么,我做错了什么?

注意事项 foundation-sites 是通过 npm 安装的。

最佳答案

您应该查看 Webpack foundation-sites loader .

示例 webpack 配置:

module.exports = {
  module: {
    loaders: [
      // **IMPORTANT** This is needed so that each foundation js file required by
      // foundation-webpack has access to the jQuery object
      { test: /foundation\/js\//, loader: 'imports?jQuery=jquery' }
    ]
  }
};

关于css - foundation-sites 包含在 webpack 中。不能使用样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46777644/

相关文章:

css - 我怎样才能防止父 div 与它的 child 一起成长?

html - 为什么在 html 中使用 ids 和 classes 为什么不只是一个?

javascript - npm left-pad 的取消发布是如何破坏代码的?

javascript - 如何在自定义 React Native 组件中实现按下事件

javascript - 类型错误 : props is undefined

html - 从子div内部访问父div的宽度

mysql - 是否没有选项可以在 sequelize 模型中映射列名

javascript - Discord.js 14 - 当成员加入时无法将图像发送到特定 channel

javascript - React 显示嵌套数组项

html - 构建我的第一个导航栏?