2017-12-26 19 views
0

スーパー人々を開始したいです!私はちょうどプログラミングのようなこの驚くべき魔法の初心者です:)そして私はこの種の 号を持っています。基本的に私はウェブパックが間違っているが、まだ ものを私に言っている知っている、私はそれを修正することができます:( を、ここでは私webpack.config.jsです:のWebPACK +バベルNPM doesntののれんの

const path = require('path') 
const webpack = require('webpack') 
const ExtractTextPlugin = require('extract-text-webpack-plugin') 

module.exports = { 
entry: [ 
'babel-polyfill', 
'./js/index.js', 
'./js/nav.js' 
'./scss/main.scss', 
], 
output: { 
filename: 'index.js', 
libraryTarget: 'commonjs', 
path: path.resolve('./dist/'), 
}, 
module: { 
rules: [ 
    { 
    test: /\.css$/, 
    loader: ExtractTextPlugin.extract(['css-loader']), 
    }, 
    { 
    test: /\.(sass|scss)$/, 
    loader: ExtractTextPlugin.extract(['css-loader', 'sass- 
loader','babel-loader']), 
    }, 
    { 
    test: /\.(png|jpg|gif|svg)$/, 
    use: [ 
     { 
     loader: 'url-loader', 
     options: { 
      limit: 8192 
     } 
     } 
    ] 
    }, 
    { 
    test: /\.js$/, 
    exclude: /(node_modules|bower_components)/, 
    use: { 
    loader: 'babel-loader', 
    options: { 
     presets: ['@babel/preset-env'] 
    } 
    } 
}, 


    ] 
}, 
plugins: [ 
new webpack.optimize.UglifyJsPlugin({ 
    output: { 
    comments: false 
    } 
}), 
    new ExtractTextPlugin({ 
    filename: 'styles.css', 
    allChunks: true, 
}), 
] 
} 

my package.json : 

{ 
"name": "simple-webpack-boilerplate", 
"version": "0.0.1", 
"scripts": { 
"start": "webpack --config webpack.config.js --watch", 
"build": "webpack --config webpack.config.js" 
}, 
"babel": { 
"presets": [ 
    "es2015" 
] 
}, 
"author": "Michał Grabowski ([email protected])", 
"license": "MIT", 
"description": "", 
"devDependencies": { 
"babel-cli": "^6.26.0", 
"babel-core": "^6.26.0", 
"babel-loader": "^8.0.0-beta.0", 
"babel-polyfill": "^6.26.0", 
"babel-preset-env": "^1.6.1", 
"babel-preset-es2015": "^6.24.1", 
"browser-sync": "^2.18.13", 
"css-loader": "0.28.7", 
"extract-text-webpack-plugin": "3.0.2", 
"file-loader": "^1.1.5", 
"node-sass": "4.7.2", 
"resolve-url-loader": "^2.2.1", 
"sass-loader": "6.0.6", 
"url-loader": "^0.6.2", 
"webpack": "^3.10.0", 
"webpack-dev-server": "^2.9.7" 
}, 
"dependencies": { 
"@babel/core": "^7.0.0-beta.35", 
"@babel/preset-env": "^7.0.0-beta.35", 
"init": "^0.1.2" 
} 
} 

そして最後に、私は、端末上の私のエラー私のNPM を開始しようとしている:

`> [email protected] start 
/Users/Niemiec/Desktop/michal_web 
> webpack --config webpack.config.js --watch 

/Users/Niemiec/Desktop/michal_web/webpack.config.js:10 
'./scss/main.scss', 
^^^^^^^^^^^^^^^^^^ 

SyntaxError: Unexpected string 
at createScript (vm.js:80:10) 
at Object.runInThisContext (vm.js:139:10) 
at Module._compile (module.js:599:28) 
at Object.Module._extensions..js (module.js:646:10) 
at Module.load (module.js:554:32) 
at tryModuleLoad (module.js:497:12) 
at Function.Module._load (module.js:489:3) 
at Module.require (module.js:579:17) 
at require (internal/module.js:11:18) 
at requireConfig 
npm ERR! Failed at the [email protected] start script. 
npm ERR! This is probably not a problem with npm. There is likely 
additional logging output above. 

npm ERR! A complete log of this run can be found in: 
npm ERR!  /Users/Niemiec/.npm/_logs/2017-12-26T21_30_23_846Z- 
debug.log 
Krzysztofs-MacBook-Pro:michal_web Niemiec$ 

` 

ヘルプ、コンマが間違った場所にある

+0

なぜあなたはCSSファイルで 'babel-loader'を使用していますか? – monssef

+0

他のjsコードはありますか?エントリポイント – Shani

+0

構文エラー基本的に私は私はいくつかのmore..iを置くprobablcy nav.jsは私のしたいが、私のJSとバベルを使用している場合ので、そのrequierがそれを持っていると考えられるので、sure..aboutバベル-loaderrをないですしています私はそう考えていたよりも多くの混乱を作ったような... –

答えて

0
entry: [ 
'babel-polyfill', 
'./js/index.js', 
'./js/nav.js' 
'./scss/main.scss', 
], 

を!!してください、あなたが移動する必要がありますあなたはentryリストで,が欠落しているように見えます'./js/nav.js'

+0

ups..looks .. :) ./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./node_modules/babelで –

+0

ERROR -loader/lib!./ scss/main.scss モジュールビルドに失敗しました:エラー:複数の構成ファイルが見つかりました。 - .babelrc - package.json しかし、私はbabelrcファイルにfintを書き込めません。 –

+0

.babelrcはルートディレクトリにある必要があります。ドットで始まるので表示されないかもしれません。隠されています。ルートディレクトリで 'ls -a'コマンドを実行してみてください。私は./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./node_modules/babelでそのエラーのようにそのをehgg ...今...今NPMを実行しますが、CN OK –

1

に1行以上の'./scss/main.scss'から,。これを試してみてください:

entry: [ 
    'babel-polyfill', 
    './js/index.js', 
    './js/nav.js' 
    './scss/main.scss', 
], 
+0

-loader/lib!./ scss/main.scss モジュールビルドに失敗しました:エラー:複数の構成ファイルが見つかりました。 1を削除してください: - .babelrc - 私はbabelrcファイルを見つけることができますis..where package.json 私はprobelm? –

関連する問題