-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.common.js
More file actions
100 lines (96 loc) · 3.58 KB
/
webpack.config.common.js
File metadata and controls
100 lines (96 loc) · 3.58 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 path = require("path");
/**
*
* @type {{root: (string|*), node_modules: (string|*)}}
*/
const paths = {
app: path.join(__dirname, "/src"), // application base path
test: path.join(__dirname, "/__test__"),
node_modules: path.join(__dirname, "/node_modules"), // modules path,
dist: path.join(__dirname, "/dist"), // build path in base path
lib: path.join(__dirname, "/lib"),
root: __dirname
};
module.exports = {
paths: paths, // reference path variable
/**
* @link https://webpack.github.io/docs/configuration.html#context
* The base path directory for resolving the entry option if output.pathinfo is set the include shortened to this directory.
*/
context: paths.app,
/* add resolve.extensions */
/**
*
* @link https://webpack.github.io/docs/configuration.html#resolve
*/
resolve: {
/**
* @link https://webpack.github.io/docs/configuration.html#resolve-root
* The directory (absolute path) that contains your modules.
* May also be an array of directories. This setting should be used to add individual directories to the search path.
* It must be an absolute path! Don’t pass something like ./app/modules.
*/
root: [paths.app],
/**
* @link https://webpack.github.io/docs/configuration.html#resolve-extensions
* An array of extensions that should be used to resolve modules.
* For example, in order to discover react jsx files, your array should contain the string ".jsx".
*/
extensions: ["", ".js", ".json"],
/**
* @link https://webpack.github.io/docs/configuration.html#resolve-modulesdirectories
* An array of directory names to be resolved to the current directory as well as its ancestors, and searched for modules.
* This functions similarly to how node finds “node_modules” directories.
* For example, if the value is ["mydir"], webpack will look in “./mydir”, “../mydir”, “../../mydir”, etc.
*/
modulesDirectories: [paths.node_modules]
},
/**
* @link https://webpack.github.io/docs/configuration.html#module
*/
module: {
/**
* @link https://webpack.github.io/docs/configuration.html#module-preloaders-module-postloaders
*/
preLoaders: [
],
/**
* https://webpack.github.io/docs/configuration.html#loaders
*/
loaders: [
{
/**
* @link https://github.com/gaearon/react-hot-loader
* npm install react-hot-loader --save-dev
*/
test: /\.js$/,
loader: "babel",
loaders: ["babel"],
exclude: /(node_modules|bower_components|fonts)/,
include: [paths.app, paths.test]
},
{
/**
* @link https://github.com/webpack/json-loader
* npm install json-loader --save-dev
*/
test: /\.json$/,
loader: "json-loader"
},
{
/**
* @link https://github.com/webpack/file-loader
* npm install file-loader --save-dev
*/
test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader: "file-loader",
include: /fonts/
}
]
},
/**
* @link https://webpack.github.io/docs/configuration.html#plugins
* will added by environment mode.
*/
plugins: []
};