zu laden Ich versuche, eine Webpack-Datei zu schreiben, die ein Projekt in reactjs mit ES6-Unterstützung erstellen wird. Hier ist meine webpack.config.jsSie benötigen möglicherweise einen geeigneten Loader, um diese Datei auf Windows mit Webpack nicht in Linux und Mac OS
webpackConfig = {
/*entry: './index.js',
output: {
path: path.resolve(__dirname, 'dist/'),
filename: 'build.js'
},*/
entry: {
lite: "./lite.js", pro: "./pro.js",
},
output: { filename: "dist/[name].js" },
plugins: [
new webpack.optimize.CommonsChunkPlugin("dist/init.js"),
new WebpackNotifierPlugin({alwaysNotify: true, title: 'Webpack'})
],
module: {
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: __dirname + '/src',
loader: 'babel-loader',
query: {
presets: ['react','es2015']
}
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader?modules')
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.less$/,
loader: "style!css!less"
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
}
// { test: /\.css$/, loader: "style-loader!css-loader" },
]
}
};
Hier ist meine .babelrc Datei
{
"presets" : ["es2015", "react"]
}
Es läuft auf Mac OS und Linux, aber mit einem Problem, wenn ich versuche, es in Windows zu laufen. irgendeine Erklärung für diesen Fehler? Es ist seltsam.
Hier ist der Fehler
ERROR in ./src/lite.js
Module parse failed: C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-content\plugins\cf7s kins-visual\src\lite.js Unexpected token (9:12)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (9:12)
at Parser.pp$4.raise (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-content\plugins \cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:2221:15)
at Parser.pp.unexpected (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-content\plug ins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:603:10)
at Parser.pp$3.parseExprAtom (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-content \plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:1822:12)
at Parser.pp$3.parseExprSubscripts (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-c ontent\plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:17 15:21)
at Parser.pp$3.parseMaybeUnary (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-conte nt\plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:1692:1 9)
at Parser.pp$3.parseExprOps (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-content\ plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:1637:21)
at Parser.pp$3.parseMaybeConditional (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp -content\plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js: 1620:21)
at Parser.pp$3.parseMaybeAssign (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-cont ent\plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:1597: 21)
at Parser.pp$3.parseParenAndDistinguishExpression (C:\xampp\htdocs\ONLINE\CF7\cf7vi sualPlugin\wp-content\plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\d ist\acorn.js:1861:32)
at Parser.pp$3.parseExprAtom (C:\xampp\htdocs\ONLINE\CF7\cf7visualPlugin\wp-content \plugins\cf7skins-visual\node_modules\webpack\node_modules\acorn\dist\acorn.js:1796:19)
@ ./lite.js 2:0-24
gibt es eine bereits ausschließen. meinst du das include: pfad.join ('_ dirname', '/ src') –
Ah, du hast Recht. Ich empfehle, das Include zu entfernen und nur das Exclude zu lassen. –