Skip to content

Instantly share code, notes, and snippets.

@jeff-kilbride
Created March 11, 2017 20:23
Show Gist options
  • Save jeff-kilbride/e58a6831546efeb43fef8fae6b2d1da6 to your computer and use it in GitHub Desktop.
Save jeff-kilbride/e58a6831546efeb43fef8fae6b2d1da6 to your computer and use it in GitHub Desktop.
css-loader error webpack.config.js
'use strict';
const webpack = require('webpack'),
path = require('path'),
ETPlugin = require('extract-text-webpack-plugin');
// Entry and build paths.
const PUBLIC_DIR = path.resolve(__dirname, 'public'),
BUILD_DIR = path.resolve(PUBLIC_DIR, 'js'),
APP_DIR = path.resolve(__dirname, 'client'),
ENTRY = path.resolve(APP_DIR, 'pack.js');
// Export the config.
module.exports = {
entry: {
app: ENTRY
},
output: {
path: BUILD_DIR,
filename: '[name].js'
},
node: {
fs: 'empty'
},
module: {
rules: [
{
test: /\.css$/,
use: ETPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
},
{
test: /\.scss$/,
use: ETPlugin.extract({
fallback: 'style-loader',
use: [
'css-loader',
'sass-loader'
]
})
},
{
test: /\.(png|jpe?g|gif|ico)$/,
loader: 'file-loader',
options: {
name: '../css/assets/[name].[hash].[ext]'
}
},
{
test: /\.(woff|woff2|eot|ttf|svg)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader',
options: {
limit: 1024,
name: '../css/assets/[name].[hash].[ext]'
}
},
],
},
plugins: [
new ETPlugin({
filename: '../css/styles.css'
}),
new webpack.ContextReplacementPlugin(/moment[\\\/]locale$/, /^\.\/(en)$/)
],
resolve: {
extensions: ['js', 'jsx', 'css', 'scss', 'sass']
},
externals: {
'jquery': 'jQuery'
},
devtool: 'eval',
devServer: {
historyApiFallback: true
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment