forked from farend/redmine_theme_farend_bleuclair
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
87 lines (85 loc) · 2.31 KB
/
webpack.config.js
File metadata and controls
87 lines (85 loc) · 2.31 KB
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
// Output先:
// bleuclair/src/scripts以下はbleuclair/javascripts/theme.jsに
// bleuclair/src/styles以下はbleuclair/stylesheets/theme.cssに
// bleuclair/src/images以下はbleuclair/stylesheets/theme.cssの内部にDataURL形式で埋め込み
// bleuclair/src/webfonts以下はbleuclair/stylesheets/webfontsに
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
module.exports = {
target: ['web', 'es5'],
entry: './src/index.js',
devtool: 'source-map',
output: {
// bleuclair.js output destination
path: path.resolve(__dirname, 'javascripts'),
filename: 'theme.js'
},
module: {
rules: [
// Compile JavaScript
{
test: /\.js$/,
exclude: /node_modules/,
// ES2015以降の新しい構文をES5の構文に変換
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
// Compile Scss
{
test: [/\.scss$/],
use: [
// jsからスタイル部分を別ファイルとして出力('../stylesheets/theme.css')
MiniCssExtractPlugin.loader,
{
// CSSスタイルシートをjsファイルに埋め込む
loader: 'css-loader',
options: {
sourceMap: true,
url: false
},
},
{
// ベンダープレフィックスを自動で付与
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [
["autoprefixer", { grid: true }],
],
},
}
},
{
// ScssファイルをCSSに変換
loader: 'sass-loader',
options: {
sourceMap: true
},
},
],
},
],
},
plugins:[
// CSS output destination
new MiniCssExtractPlugin({ filename: '../stylesheets/theme.css' }),
],
optimization: {
// CSSを最小化
minimizer: [new CssMinimizerPlugin({
minimizerOptions: {
preset: [
"default",
{
colormin: { exclude: true },
},
],
},
})],
}
}