-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
102 lines (100 loc) · 2.18 KB
/
webpack.common.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
99
100
101
102
// 各種プラグインのロード
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const AutoPrefixer = require('autoprefixer');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const app = {
entry: {
app: [
'./src/js/main.js',
'./src/scss/style.scss',
],
},
output: {
filename: 'js/[name].min.js',
// サブディレクトリー以下に公開できるようにするためにパスの起点を省略する
publicPath: '',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
enforce: 'pre',
use: [
{ loader: 'eslint-loader' },
],
},
{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.scss$/,
use: [
{ loader: MiniCssExtractPlugin.loader },
{ loader: 'css-loader' },
{
loader: 'postcss-loader',
options: {
plugins: [
AutoPrefixer(),
],
},
},
{ loader: 'sass-loader' },
],
},
{
test: /\.html$/,
loader: 'html-loader',
options: {
minimize: true,
},
},
{
test: /\.(jpe?g|png|gif|svg)$/,
use: {
loader: 'file-loader',
options: {
name: (resourcePath, _) => {
const basePath = path.join(__dirname, 'src/');
return resourcePath
.substring(basePath.length)
.replace(/\\/g, '/');
},
esModule: false,
},
},
},
],
},
resolve: {
extensions: ['.js'],
},
plugins: [
new MiniCssExtractPlugin({
filename: 'css/style.min.css',
}),
new CopyWebpackPlugin(
[
{
context: 'src/img',
from: '**/*',
to: 'img',
},
],
),
new HtmlWebpackPlugin({
template: "src/index.html"
}),
],
performance: {
hints: false,
},
};
module.exports = {
app: app,
};