-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
104 lines (94 loc) · 2.78 KB
/
webpack.config.js
File metadata and controls
104 lines (94 loc) · 2.78 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
100
101
102
103
104
// webpack.config.js
const path = require('path');
const webpack = require('webpack');
const appDirectory = path.resolve(__dirname, '.');
const babelLoaderConfiguration = {
test: /\.js$/,
include: [
path.resolve(appDirectory, 'index.web.js'),
path.resolve(appDirectory, 'src'),
path.resolve(appDirectory, 'node_modules/react-native-uncompiled'),
],
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
plugins: ['react-native-web'],
presets: ['react-native', 'es2015','react']
}
}
};
const imageLoaderConfiguration = {
test: /\.(gif|jpe?g|png|svg)$/,
use: {
loader: 'url-loader',
options: {
name: '[name].[ext]'
}
}
};
module.exports = {
// your web-specific entry file
// entry: "./index.web.js",
entry: {
app: './index.web.js',
vendors: './index.js',
},
// configures where the build ends up
output: {
filename: '[name].web.js',
path: path.resolve(appDirectory, 'dist')
},
// ...the rest of your config
module: {
rules: [
babelLoaderConfiguration,
imageLoaderConfiguration
]
},
plugins: [
// `process.env.NODE_ENV === 'production'` must be `true` for production
// builds to eliminate development checks and reduce build size. You may
// wish to include additional optimizations.
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
__DEV__: process.env.NODE_ENV !== 'production' || true
})
],
resolve: {
// If you're working on a multi-platform React Native app, web-specific
// module implementations should be written in files using the extension
// `.web.js`.
extensions: [ '.web.js', '.js', '.wasm' ]
},
mode: 'development',
}
// module.exports = {
// entry: "./index.js",
// output: {
// path: path.resolve(__dirname, "dist"),
// filename: "index.js",
// },
// mode: "development",
// plugins: [
// // `process.env.NODE_ENV === 'production'` must be `true` for production
// // builds to eliminate development checks and reduce build size. You may
// // wish to include additional optimizations.
// new webpack.DefinePlugin({
// 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
// __DEV__: process.env.NODE_ENV !== 'production' || true
// })
// ],
// module: {
// rules: [
// babelLoaderConfiguration,
// imageLoaderConfiguration
// ]
// },
// resolve: {
// // If you're working on a multi-platform React Native app, web-specific
// // module implementations should be written in files using the extension
// // `.web.js`.
// extensions: [ '.web.js', '.js', '.wasm' ]
// },
// };