Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

antd get error (function (exports, require, module, __filename, __dirname) { @import './themes/default'; #893

Closed
zry754331875 opened this issue Jan 20, 2019 · 1 comment
Labels

Comments

@zry754331875
Copy link

When l yarn start server.js throw error, such as this:
(function (exports, require, module, __filename, __dirname) { @import './themes/default';

Here is my client webpackConfig
`const ExtractTextPlugin = require("extract-text-webpack-plugin");
const antdTheme = require("../antdTheme"); // <- Include variables to override antd theme

const extractLess = new ExtractTextPlugin({
filename: "static/css/[name].[contenthash].css",
disable: process.env.NODE_ENV === "development" // disable this during development
});

module.exports = (config, webpack) => ({
...config,
module: {
...config.module,
rules: [
...config.module.rules,
{
test: /.js$/,
exclude: /node_modules/,
loader: "babel-loader",
options: {
plugins: [["import", { libraryName: "antd", style: true }]]
}
},
{
test: /.less$/,
// use the ExtractTextPlugin instance
use: extractLess.extract({
use: [
{
loader: "style-loader"
},
{
loader: "css-loader"
},
{
loader: "less-loader",
options: {
modifyVars: antdTheme
}
}
],
// use style-loader in development
fallback: "style-loader"
})
}
]
},
plugins: [
...config.plugins,
extractLess // <- Add the ExtractTextPlugin instance here
]
});`

Here is my server's webConfig.
module.exports = (config, webpack) => ({ ...config, module: { ...config.module, rules: [...config.module.rules], }, plugins: [ ...config.plugins, new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1, }), ], })

Here is mine razzle.config.js;
module.exports = { modify: (config, { target, dev }, webpack) => { const targetName = target === 'node' ? 'server' : 'client' return require(./webpack/${targetName})(config, webpack) }, }

@nimaa77
Copy link
Collaborator

nimaa77 commented Mar 17, 2020

Closed due to inactivity. Holler if this is a mistake, and we'll re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants