我正在努力安装fousionjs6和webpack。我有一个“意外的令牌导入”。我认为这应该和巴别塔有关,但我找不到问题出在哪里。
我使用foundation-sites 6.4.1
这是我的webpack.config.js
var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var express = require('express')
var path = require('path')
module.exports = {
module: {
loaders: [
{ test: /\.json$/, loader: 'json' },
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
include: path.join(__dirname, 'src'),
},
{ test: /\.scss$/, loader: ExtractTextPlugin.extract('style-loader', 'css!sass') },
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
{ test: /\.(eot|svg|ttf|woff2?).*$/, loader: 'url?limit=10000' },
{ test: /\.(png|jpg|jpeg).*$/, loader: 'url?limit=10000' },
],
},
plugins: [
new ExtractTextPlugin('bundle.[hash].css'),
new HtmlWebpackPlugin({
template: 'src/index.html.ejs',
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
}),
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /fr/),
],
entry: ['./src/index.js', './src/index.scss'],
output: {
path: 'build/',
filename: 'bundle.[hash].js',
},
devServer: {
inline: true,
stats: {
chunks: false,
}
}
}在我的.babelrc
{
"presets": ["es2015", "es2016", "es2017", "stage-0", "react"],
"plugins": ["transform-async-to-generator", "transform-runtime"]
}在我的index.html.ejs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Title</title>
</head>
<body>
<div id="app"></div>
</body>
</html>在我的index.js中,文件的顶部有以下内容:
import 'script!jquery'
import 'script!what-input'
import 'script!foundation-sites'有没有人有主意?
谢谢
发布于 2017-07-24 18:05:53
entry point of foundation-sites使用ES模块(import/export),但是您没有将babel-loader应用于node_modules,因此它们不会被转换。您也许能够导入已经转换的版本:
import 'foundation-sites/dist/js/foundation.js'从webpack 2开始开箱即支持ES模块,强烈建议您升级到webpack。official migration guide应该会帮助你做到这一点。
https://stackoverflow.com/questions/45276232
复制相似问题