質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%

Q&A

解決済

1回答

3398閲覧

webpack2でExtractTextPluginのエラーを解決する方法を教えて下さい。

退会済みユーザー

退会済みユーザー

総合スコア0

0グッド

0クリップ

投稿2017/04/11 07:26

webpack2のExtractTextPluginを使用するとエラーが出てしまうのですが、
解決方法がわからず、困っています。
解決方法を教えていただきたいです。

// webpack.config.js require('babel-polyfill'); var webpack = require('webpack'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var autoprefixer = require('autoprefixer'); var path = require('path'); module.exports = { devtool: 'inline-source-map', context: __dirname, entry: { 'client': './src/client/index.js' }, output: { path: '../app/assets/javascripts', filename: '[name]/bundle.js' }, module: { loaders: [ { test: /^((?!\.global).)*(scss|css)$/, loader: ExtractTextPlugin.extract( 'style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[local]___[hash:base64:5]!postcss-loader', 'resolve-url', 'sass' ) }, { test: /\.global.(scss|css)$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader', 'resolve-url', 'sass') }, { test: /\.jsx$/, exclude: /node_modules/, loader: 'babel-loader' }, { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }, { test: /\.(jpg|png|gif)$/, loader: 'url-loader', exclude: /node_modules/ } ] }, plugins: [ new ExtractTextPlugin('../stylesheets/[name]/bundle.scss', { ignoreOrder: true } ) ] };

エラー内容

configuration has an unknown property 'postcss'. These properties are valid: client.1 | object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? } client.1 | For typos: please correct them. client.1 | For loader options: webpack 2 no longer allows custom properties in configuration. client.1 | Loaders should be updated to allow passing options via loader options in module.rules. client.1 | Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader: client.1 | plugins: [ client.1 | new webpack.LoaderOptionsPlugin({ client.1 | // test: /\.xxx$/, // may apply this only for some modules client.1 | options: { client.1 | postcss: ... client.1 | } client.1 | }) client.1 | ] client.1 | - configuration.output.path: The provided value "../app/assets/javascripts" is not an absolute path! client.1 | - configuration.resolve has an unknown property 'modulesDirectories'. These properties are valid: client.1 | object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? } client.1 | - configuration.resolve.extensions[0] should not be empty.

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

エラーを参考にpostcssから削除して、順番に検証してみるといいと思いますが、2であれば書き方が異なるような気もします。

Migrating from v1 to v2

自分の場合は、loaderとoptionsを分離する記法を使用しています。
長くなるけどわかりやすいので。。。

javascript

1:(参考例) 2const PostcssCssnext = require('postcss-cssnext'); 3: 4 rules: [ 5 { 6 test: /\.css$/, 7 use: ExtractTextPlugin.extract({ 8 fallback: 'style-loader', 9 use: [ 10 { 11 loader: 'css-loader', 12 options: { 13 sourceMap: true, 14 importLoaders: 1 15 } 16 }, 17 { 18 loader: 'postcss-loader', 19 options: { 20 plugins: () => [ 21 PostcssCssnext({ 22 browsers: ['last 2 versions'], 23 features: { 24 rem: true 25 } 26 }) 27 ] 28 } 29 } 30 ] 31 }) 32 }, 33

投稿2017/04/26 03:41

tomomo

総合スコア430

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2017/04/28 12:46

ありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問