【发布时间】:2018-01-14 20:33:34
【问题描述】:
我正在尝试通过创建静态 index.html 页面并通过 index.html 中的 head 标记导入必要的文件,将 Materialize.css 与我的 Next.js 应用程序一起使用。
我的index.html 包含以下内容:
<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css" media="screen,projection"/>
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
<script src="bundle.js"></script>
</body>
</html>
我创建了一个next.config.js 文件,其中包含以下内容:
module.exports = {
webpack: (config, { buildId, dev }) => {
entry: './pages/index.js',
output: {
filename: 'bundle.js'
}
return config
},
webpackDevMiddleware: config => {
// Perform customizations to webpack dev middleware config
// Important: return the modified config
return config
}
}
运行npm run dev 时出现以下错误:
输出:'bundle.js'
^ SyntaxError: Unexpected token :
如何编辑此配置文件以创建bundle.js 并将我的index.js 提供给我的index.html?
【问题讨论】:
-
无需在 Webpack 配置中进行配置,Next.js 会为您提供开箱即用的处理。您可以使用
next export导出静态站点。阅读static export in Next.js。
标签: javascript webpack materialize next.js