98 lines
2.0 KiB
JavaScript
98 lines
2.0 KiB
JavaScript
const path = require('path');
|
|
|
|
const ExtractCssChunks = require('extract-css-chunks-webpack-plugin');
|
|
const globImporter = require('node-sass-glob-importer');
|
|
const webpack = require('webpack');
|
|
|
|
const isProduction = !!process.argv.find((arg) => '--production' === arg);
|
|
|
|
const config = {
|
|
mode: isProduction ? 'production' : 'development',
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.js$/,
|
|
exclude: [
|
|
/(node_modules\/(?!@avocado|contempo))/,
|
|
],
|
|
use: {
|
|
loader: 'babel-loader',
|
|
options: {},
|
|
},
|
|
},
|
|
// Styles.
|
|
{
|
|
test: /\.(?:sa|sc|c)ss$/,
|
|
exclude: /\.raw\./,
|
|
use: [
|
|
{
|
|
loader: ExtractCssChunks.loader,
|
|
options: {
|
|
hot: true,
|
|
},
|
|
},
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
// 2 because postcss & sass.
|
|
importLoaders: 2,
|
|
},
|
|
},
|
|
{
|
|
loader: 'postcss-loader',
|
|
},
|
|
{
|
|
loader: 'sass-loader',
|
|
options: {
|
|
importer: globImporter(),
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
test: /\.(?:sa|sc|c)ss$/,
|
|
include: /\.raw\./,
|
|
use: [
|
|
{
|
|
loader: 'raw-loader',
|
|
},
|
|
{
|
|
loader: 'postcss-loader',
|
|
},
|
|
{
|
|
loader: 'sass-loader',
|
|
options: {
|
|
importer: globImporter(),
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
output: {
|
|
// Worker happiness.
|
|
globalObject: `(typeof self === 'undefined' ? this : self)`,
|
|
path: path.resolve(__dirname, 'dist'),
|
|
filename: '[name].js',
|
|
},
|
|
plugins: [
|
|
new ExtractCssChunks({
|
|
filename: '[name].css',
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {},
|
|
modules: [
|
|
path.join(__dirname, 'node_modules'),
|
|
path.join(__dirname, 'scss'),
|
|
],
|
|
},
|
|
resolveLoader: {
|
|
modules: [
|
|
path.join(__dirname, 'node_modules'),
|
|
],
|
|
},
|
|
};
|
|
|
|
module.exports = config;
|