Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Moment optimisation
const path = require('path');
const glob = require('glob');
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
const {ANALYZE} = process.env;
const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
module.exports = {
webpack: (config, {dev, isServer}) => {
if (ANALYZE) {
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: isServer ? 8888 : 8889,
openAnalyzer: true
}));
}
config.module.rules.push(
{
test: /\.(css|scss)/,
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]'
}
},
{
test: /\.css$/,
use: ['babel-loader', 'raw-loader', 'postcss-loader']
},
{
test: /\.s(a|c)ss$/,
use: ['babel-loader', 'raw-loader', 'postcss-loader',
{
loader: 'sass-loader',
options: {
includePaths: ['styles', 'node_modules']
.map(d => path.join(__dirname, d))
.map(g => glob.sync(g))
.reduce((a, c) => a.concat(c), [])
}
}
]
}
);
config.plugins.push(new MomentLocalesPlugin({
localesToKeep: ['ru'],
}));
return config;
},
};
module.exports = {
plugins: [
require('postcss-easy-import')({prefix: '_'}), // keep this first
require('autoprefixer')({ /* ...options */ }), // so imports are auto-prefixed too
require('cssnano')()
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.