DefinitelyTyped/types/mini-css-extract-plugin/mini-css-extract-plugin-tests.ts
2018-03-23 13:48:42 +08:00

59 lines
1.4 KiB
TypeScript

import webpack = require('webpack');
import MiniCssExtractPlugin = require('mini-css-extract-plugin');
let configuration: webpack.Configuration;
configuration = {
// The standard entry point and output config
entry: {
posts: './posts',
post: './post',
about: './about',
},
output: {
filename: '[name].js',
chunkFilename: '[id].js',
},
module: {
rules: [
// Extract css files
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
// Optionally extract less files
// or any other compile-to-css language
{
test: /\.less$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'style-loader',
],
},
// You could also use other loaders the same way. I. e. the autoprefixer-loader
],
},
// Use the plugin to specify the resulting filename (and add needed behavior to the compiler)
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
}),
],
};
configuration = {
// ...
plugins: [new MiniCssExtractPlugin()],
};
configuration = {
// ...
plugins: [
new MiniCssExtractPlugin({
filename: 'styles.css',
chunkFilename: 'style.css',
}),
],
};