forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack-production.config.js
95 lines (92 loc) · 2.41 KB
/
webpack-production.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
const webpack = require('webpack');
const path = require('path');
const buildPath = path.resolve(__dirname, 'build');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const config = {
// Entry point to the project
entry: [
'./node_modules/babel-polyfill/lib/index.js',
path.resolve(__dirname, 'src/app/app.js'),
],
// Webpack config options on how to obtain modules
resolve: {
// When requiring, you don't need to add these extensions
extensions: ['', '.js', '.md', '.txt'],
alias: {
// material-ui requires will be searched in src folder, not in node_modules
'material-ui': path.resolve(__dirname, '../src'),
'react': 'react-lite',
'react-dom': 'react-lite',
'react-tap-event-plugin': 'react-lite/lib/react-tap-event-plugin',
},
},
devtool: 'source-map',
// Configuration for server
devServer: {
contentBase: 'build',
// Required for webpack-dev-server
outputPath: buildPath,
},
// Output file config
output: {
path: buildPath, // Path of output file
filename: 'app.js', // Name of output file
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
output: {
comments: false,
},
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
// Allows error warnings but does not stop compiling. Will remove when eslint is added
new webpack.NoErrorsPlugin(),
// Transfer Files
new CopyWebpackPlugin([
{from: 'src/www/css', to: 'css'},
{from: 'src/www/images', to: 'images'},
{from: 'src/www/index.html'},
{from: 'src/www/versions.json'},
]),
],
module: {
// Allow loading of non-es5 js files.
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.json$/,
loader: 'json-loader',
},
{
test: /\.txt$/,
loader: 'raw-loader',
include: path.resolve(__dirname, 'src/app/components/raw-code'),
},
{
test: /\.md$/,
loader: 'raw-loader',
},
{
test: /\.css$/,
loader: 'style-loader!css-loader',
},
],
},
eslint: {
configFile: '../.eslintrc',
},
};
module.exports = config;