-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.css.config.js
98 lines (94 loc) · 2.55 KB
/
webpack.css.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const path = require('path')
const webpack = require('webpack')
const ExtractTextWebpackPlugin = require('extract-text-webpack-plugin')
const SassLintPlugin = require('sass-lint-webpack')
const OptimizeCSSAssets = require("optimize-css-assets-webpack-plugin")
const DashboardPlugin = require("webpack-dashboard/plugin")
const CopyPlugin = require('copy-webpack-plugin')
let config = {
entry: {
home: './assets/stylesheets/home.scss',
other: './assets/stylesheets/other.scss'
},
mode: process.env.NODE_ENV || 'development',
output: {
filename: '[name].css',
path: path.resolve(__dirname, './src/assets/stylesheets')
},
module: {
rules: [
{
test: /\.scss$/,
use: ExtractTextWebpackPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader', 'postcss-loader'],
})
},
{
test: /\.(jpe?g|png|gif|svg)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8000,
name: '../../[path][name]_[hash:5].[ext]'
}
},
{
loader: 'image-webpack-loader',
options: {
gifsicle: {
interlaced: false
},
mozjpeg: {
progressive: true,
arithmetic: false
},
optipng: false,
pngquant: {
floyd: 0.5,
speed: 2
},
svgo: {
plugins: [
{ removeTitle: true },
{ convertPathData: false }
]
}
}
}
]
},
{
test: /\.(woff2|ttf)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 10,
name: '../fonts/[name].[ext]'
}
}
]
},
]
},
plugins: [
new SassLintPlugin({
ignorePlugins: ['extract-text-webpack-plugin']
}),
new DashboardPlugin(),
new ExtractTextWebpackPlugin('[name].css')
]
}
module.exports = config;
if (process.env.NODE_ENV === 'production') {
module.exports.plugins.push(
new OptimizeCSSAssets(),
new ExtractTextWebpackPlugin('../../../public/assets/stylesheets/[name].css'),
new CopyPlugin([
{ from: 'src/assets/fonts', to: path.resolve(__dirname, './public/assets/fonts'), toType: 'dir' },
{ from: 'src/assets/images', to: path.resolve(__dirname, './public/assets/images'), toType: 'dir' },
])
);
}