78 行
JavaScript
78 行
JavaScript
|
const path = require( 'path' );
|
||
|
const webpack = require( 'webpack' );
|
||
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||
|
|
||
|
module.exports = ( env, options ) => {
|
||
|
return {
|
||
|
entry: './src/block.js',
|
||
|
|
||
|
output: {
|
||
|
path: path.resolve( __dirname, 'build' ),
|
||
|
filename: 'block.js',
|
||
|
},
|
||
|
|
||
|
stats: {
|
||
|
children: true,
|
||
|
warningsFilter: [
|
||
|
/\-\-underline\-color/,
|
||
|
]
|
||
|
},
|
||
|
|
||
|
devtool: 'cheap-eval-source-map',
|
||
|
|
||
|
module: {
|
||
|
rules: [
|
||
|
{
|
||
|
test: /\.jsx$|\.es6$|\.js$/,
|
||
|
use: {
|
||
|
loader: 'babel-loader',
|
||
|
options: {
|
||
|
presets: ['react'],
|
||
|
}
|
||
|
},
|
||
|
exclude: /(node_modules|bower_components)/
|
||
|
},
|
||
|
{
|
||
|
test: /\.css$/,
|
||
|
use: [
|
||
|
MiniCssExtractPlugin.loader,
|
||
|
{
|
||
|
loader: 'css-loader',
|
||
|
options: {
|
||
|
importLoaders: 1,
|
||
|
minimize: ( options.mode == 'production' ? true : false ),
|
||
|
sourceMap: true,
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
loader: 'postcss-loader',
|
||
|
options: {
|
||
|
plugins: [ require( 'autoprefixer' ) ]
|
||
|
}
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
{
|
||
|
test: /\.(png|jpg|gif)$/,
|
||
|
use: [
|
||
|
{
|
||
|
loader: 'file-loader',
|
||
|
options: {
|
||
|
name: '[name].[ext]',
|
||
|
outputPath: 'images/'
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
|
||
|
plugins: [
|
||
|
new MiniCssExtractPlugin({
|
||
|
filename: 'style.css',
|
||
|
chunkFilename: '[id].css'
|
||
|
})
|
||
|
],
|
||
|
|
||
|
}
|
||
|
};
|