2017-12-04 8 views
0

でScssをコンパイルしています。コンパイル済みのCSSファイルを作成してwebpack-dev-serverを追加したときdistフォルダに移動します。私はこれは私がWebpack

var ExtractTextPlugin = require('extract-text-webpack-plugin'); 

module.exports = { 
    entry: ['./js/app.js', './scss/main.scss'], 
    output: { 
    filename: 'dist/bundle.js' 
    }, 
    module: { 

    rules: [ 
     /* 
     your other rules for JavaScript transpiling go in here 
     */ 
     { // regular css files 
     test: /\.css$/, 
     loader: ExtractTextPlugin.extract({ 
      loader: 'css-loader?importLoaders=', 
     }), 
     }, 
     { // sass/scss loader for webpack 
     test: /\.(sass|scss)$/, 
     loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) 
     } 
    ] 
    }, 
    plugins: [ 
    new ExtractTextPlugin({ // define where to save the file 
     filename: 'dist/[name].bundle.css', 
     allChunks: true, 
    }), 
    ], 
}; 

を提出、これまで私のwebpack.config.jsでこれを持っていたので、十分に簡単だろうと思った。しかし、私は

throw new _ValidationError2.default(ajv.errors, name); 

を取得していますWebPACKのコマンドを実行しているとき、私はよく分かりませんどうして私はそれが古くなったものを使っていたのかもしれないと思っていたので、私は検索に行きました。ああまた、私はここにWindowsコンピュータ上だと

は、事前に、私はちょうどそれが働いていない理由を知りたい私のpackage.json

{ 
    "name": "portfolio_site", 
    "version": "1.0.0", 
    "description": "", 
    "main": "webpack.config.js", 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1", 
    "build": "webpack", 
    "start": "webpack-dev-server" 
    }, 
    "author": "", 
    "license": "ISC", 
    "devDependencies": { 
    "css-loader": "^0.28.7", 
    "extract-text-webpack-plugin": "^3.0.2", 
    "node-sass": "^4.7.2", 
    "sass-loader": "^6.0.6", 
    "style-loader": "^0.19.0", 
    "webpack": "^3.9.1", 
    "webpack-dev-server": "^2.9.5" 
    }, 
    "dependencies": {} 
} 

おかげです。あなたが持っているあなたのWebPACKの設定で

答えて

0

{ // regular css files 
     test: /\.css$/, 
     loader: ExtractTextPlugin.extract({ 
      loader: 'css-loader?importLoaders=', 
     }), 
     }, 
     { // sass/scss loader for webpack 
     test: /\.(sass|scss)$/, 
     loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) 
     } 

代わりに、それは次のようになります。

{ // regular css files 
     test: /\.css$/, 
     use: ExtractTextPlugin.extract({ 
      use: 'css-loader?importLoaders=', 
     }), 
     }, 
     { // sass/scss loader for webpack 
     test: /\.(sass|scss)$/, 
     use: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) 
     } 

"ローダー" は廃止されました。

REF:私はこれを試してみたが、私は私が今エラーCを取得しないときhttps://github.com/webpack-contrib/extract-text-webpack-plugin/issues/569

+0

:\ユーザーは\ HTML \ portfolio_site \ node_modules \抽出・テキストのWebPACK - プラグインの\ distのコーディングデスクトップ\ \私\ \ lib \ helpers.js:15 return chunk.isInitial()|| chunk.parents.length === 0; – laughingllama42

+0

node_modulesフォルダを削除して、使用しているものに基づいて 'npm install'または' yarn'を実行し、まだエラーが発生していないかどうか確認してください。 – nizantz

+0

入力@nizantzありがとうございます。たぶん、これは窓の問題ですか? – laughingllama42