Skip to content

Commit 2dfe58b

Browse files
committed
fix: make webpack config working again
1 parent fb59679 commit 2dfe58b

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

webpack/webpack.config.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,37 @@ const context = path.join(__dirname, '../src/js')
1212
export const outputPath = 'www'
1313

1414

15-
const getExtractTextPluginLoader = options => {
15+
const getRules = options => {
1616
const useCssModules = JSON.parse(process.env.USE_CSS_MODULES)
17-
const cssLoaderArgs = useCssModules ?
18-
'?modules&importLoaders=2&localIdentName=[name]__[local]__[hash:base64:5]' : ''
19-
20-
return [ `css${cssLoaderArgs}` + '!postcss' + '!sass']
21-
}
2217

23-
const getRules = options => {
2418
return [
2519
{
2620
test: JS_REGEX,
27-
loaders: ['babel'],
21+
loaders: ['babel-loader'],
2822
exclude: /node_modules/
2923
},
3024
{
3125
test: CSS_REGEX,
3226
loader: ExtractTextPlugin.extract({
33-
fallbackLoader: "style",
34-
loader: getExtractTextPluginLoader(options)
35-
})
27+
fallbackLoader: "style-loader",
28+
loader: [
29+
{ loader: 'css-loader', query: {
30+
modules: useCssModules,
31+
importLoaders: useCssModules ? 2 : '',
32+
localIdentName: useCssModules ? '[name]__[local]__[hash:base64:5]' : ''
33+
} },
34+
{ loader: 'postcss-loader' },
35+
{ loader: 'sass-loader', options: {} }
36+
]
37+
}),
3638
},
3739
{
3840
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
39-
loader: "file"
41+
loader: "file-loader"
42+
},
43+
{
44+
test: /\.json$/,
45+
loader: "json-loader"
4046
}
4147
]
4248
}
@@ -64,14 +70,6 @@ const config = options => {
6470
githubRepositoryUrl: 'https://github.com/matteocng/react-flag-icon-css'
6571
}),
6672
new ExtractTextPlugin('bundle.css'),
67-
new webpack.LoaderOptionsPlugin({
68-
options: {
69-
context: __dirname,
70-
postcss: [
71-
autoprefixer
72-
]
73-
}
74-
}),
7573
new webpack.DefinePlugin({
7674
__USE_CSS_MODULES__: JSON.stringify(JSON.parse(process.env.USE_CSS_MODULES || 'true'))
7775
})

0 commit comments

Comments
 (0)