将css添加为<link tag =“”that =“”@ import =“”another =“”css =“”from =“”node_modules =“”

时间:2018-01-04 13:03:21

标签: webpack webpack-2 next.js ssr

=“”

如何导入此css .. /styles/app.css只包含一个导入...

@import 'normalize.css';

_document标记为<link

import stylesheet from 'styles/app.css'

....

<link rel="stylesheet" href={stylesheet) />

next.config.js配置...

config.module.rules.push({
    test: /\.css$/,
    loader: 'emit-file-loader',
    options: {name: 'dist/[path][name].[ext]'}
});
config.module.rules.push({
    test: /\.css$/,
    use: [                        {
        loader: 'file-loader',
        options: {
            context: 'public',
            name: 'styles/[name]-[hash].[ext]',
            publicPath: '/',
        },
    }, 'postcss-loader']
});

但是dist文件夹中生成的结构是错误的

enter image description here

我在控制台上获得了404 ..

enter image description here

检查online here

0 个答案:

没有答案