-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathwebpack.common.js
More file actions
99 lines (96 loc) · 2.73 KB
/
webpack.common.js
File metadata and controls
99 lines (96 loc) · 2.73 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
88
89
90
91
92
93
94
95
96
97
98
99
const webpack = require('webpack');
const convert = require('koa-connect');
const history = require('connect-history-api-fallback');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const commonPaths = require('./paths');
module.exports = {
entry: commonPaths.entryPath,
module: {
rules: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: /(node_modules)/,
options: {
presets: [
[
'@babel/preset-env',
{
targets: {
esmodules: true,
},
useBuiltIns: 'usage',
},
],
'@babel/preset-react',
],
plugins: [
'@babel/transform-react-constant-elements',
'@babel/transform-react-inline-elements',
'transform-react-remove-prop-types',
'transform-react-pure-class-to-function',
'@babel/plugin-transform-runtime',
'react-hot-loader/babel',
// Stage 2 https://github.com/babel/babel/tree/master/packages/babel-preset-stage-2
['@babel/plugin-proposal-decorators', { legacy: true }],
'@babel/plugin-proposal-function-sent',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-numeric-separator',
'@babel/plugin-proposal-throw-expressions',
// Stage 3
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-syntax-import-meta',
['@babel/plugin-proposal-class-properties', { loose: true }],
'@babel/plugin-proposal-json-strings',
],
},
},
{
test: /\.(png|jpg|gif|svg)$/,
use: [
{
loader: 'file-loader',
options: {
outputPath: commonPaths.imagesFolder,
},
},
],
},
{
test: /\.(woff2|ttf|woff|eot)$/,
use: [
{
loader: 'file-loader',
options: {
outputPath: commonPaths.fontsFolder,
},
},
],
},
],
},
// serve: {
// add: app => {
// app.use(convert(history()));
// },
// content: commonPaths.entryPath,
// dev: {
// publicPath: commonPaths.outputPath,
// },
// open: true,
// },
resolve: {
modules: ['src', 'node_modules'],
extensions: ['*', '.js', '.jsx', '.css', '.scss'],
},
plugins: [
new webpack.ProgressPlugin(),
new HtmlWebpackPlugin({
template: commonPaths.templatePath,
}),
new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'async',
}),
],
};