-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
91 lines (87 loc) · 2.67 KB
/
webpack.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
const path = require('path');
const HtmlPlugin = require('html-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
main: path.resolve(__dirname, 'src', 'index.jsx')
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'resources/js/bundle.js?[hash]'
},
resolve: {
extensions: ['.js', '.jsx'],
alias: {
components: path.resolve(__dirname, 'src', 'components'),
containers: path.resolve(__dirname, 'src', 'containers'),
actions: path.resolve(__dirname, 'src', 'actions'),
reducers: path.resolve(__dirname, 'src', 'reducers'),
}
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
}
},
{
test: /\.s?css$/,
use: ['style-loader', MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
},
{
test: /\.(eot|ttf|woff|woff2)$/,
loader: 'file-loader?name=resources/fonts/[name].[ext]'
},
{
test: /\.(svg|gif|jpe?g|png)$/,
loader: 'file-loader?name=resources/images/[name].[ext]'
}
]
},
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: false
}),
new OptimizeCSSAssetsPlugin({})
]
},
devServer: {
historyApiFallback: true,
},
plugins: [
new HtmlPlugin({
title: 'Linker',
template: path.resolve(__dirname, 'src', 'index.html'),
filename: 'index.html',
minify: {removeScriptTypeAttributes: true}
}),
new MiniCssExtractPlugin({filename: 'resources/css/style.css?[contenthash]'}),
new CopyWebpackPlugin([
{
from: 'src/locale',
to: 'resources/locale'
},
{
from: 'src/data',
to: 'resources/data'
},
{
from: 'src/robots.txt',
to: 'robots.txt'
},
{
from: 'src/images/favicon.png',
to: 'resources/images/favicon.png'
}
]),
]
};