-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathwebpack.config.js
112 lines (97 loc) · 2.34 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const path = require('path');
const Webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const __uiRoot = path.resolve(__dirname, './app');
const isProduction = process.env.NODE_ENV === 'production';
const webpackConfig = {
entry: {
app: [
`${__uiRoot}/index.entry.js`
],
},
output: {
path: path.resolve(__dirname, 'build'),
publicPath: '/'
},
mode: isProduction ? 'production' : 'development',
devtool: !isProduction ? 'sourcemap' : false,
resolve: {
extensions: [ '.js', '.jsx' ],
modules: [ 'node_modules', 'app' ],
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
},
{
test: /\.pcss$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1
}
}, 'svg-transform-loader/encode-query', 'postcss-loader'],
},
{
test: /\.(jpg|png|gif)$/,
loader: 'file-loader',
options: {
name: 'static/[name].[hash].[ext]',
},
},
{
test: /\.css$/,
loader: ['style-loader', 'css-loader'],
},
{
test: /\.svg(\?.*)?$/,
use: [
'url-loader',
'svg-transform-loader'
],
},
{
test: /\.json$/,
loader: 'file-loader',
options: {
name: 'static/[name].[hash].[ext]',
},
},
]
},
stats: 'errors-only',
plugins: [
new CopyWebpackPlugin([ {
from: path.resolve(__dirname, './app/static'),
to: path.resolve(__dirname, './build/static')
}]),
new Webpack.DefinePlugin({
__DEV__: !isProduction,
__PROD__: isProduction
}),
new HtmlWebpackPlugin({
title: 'Main app',
template: './app/pages/index.html',
}),
new HtmlWebpackPlugin({
title: 'Main app',
template: './app/pages/landing.html',
filename: 'landing.html',
}),
new HtmlWebpackPlugin({
title: 'Layout docs',
template: './app/pages/layout-docs.html',
filename: 'layout-docs.html',
}),
],
devServer: {
disableHostCheck: true
}
};
module.exports = webpackConfig;