【问题标题】:foundation-sites inclusion in webpack. Can't use stylings基础站点包含在 webpack 中。不能使用样式
【发布时间】:2018-03-28 09:46:32
【问题描述】:

我是整个 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;

我的目录结构:

网络应用程序正常运行,但在渲染时:

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 安装的。

【问题讨论】:

    标签: css node.js reactjs webpack


    【解决方案1】:

    您应该查看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' }
        ]
      }
    };
    

    【讨论】:

      猜你喜欢
      • 2015-06-19
      • 1970-01-01
      • 2011-03-22
      • 2014-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-23
      相关资源
      最近更新 更多