Primeract和nextjs webpack配置

时间:2019-09-04 13:20:49

标签: css webpack next.js primereact

如何将CSS导入到nextjs 我根据nextjs文档做到了。但是它给出了错误。我必须安装loader。但是我是webpack的新手。我没有找到如何webpack配置。请提出解决方案。

1 个答案:

答案 0 :(得分:0)

webpack.config.js文件中,这对我有用:

var webpack = require('webpack');
var path = require('path');
var nodeExternals = require('webpack-node-externals');

module.exports = {
    target: 'web',
    entry: './src/index.js',
    output: {
    path: path.resolve(__dirname, 'build'),
    filename: 'index.js',
    libraryTarget: 'commonjs2'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                include: path.resolve(__dirname, 'src'),
                exclude: /(node_modules|bower_components|build)/,
                use: {
                loader: 'babel-loader',
                options: {
                    presets: ['env']
                }
                }
            },
            {
                test: /\.css$/i,
                use: ['style-loader', 'css-loader'],
            },
            {
                test: /\.(png|jpg|woff|woff2|eot|ttf|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                loader: 'url-loader?limit=100000'
            }
        ]
    },
    mode: 'development'
};

实际上,您需要正确的装载机才能从ES6装载到ES5。

这应该有效。