-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathwebpack.config.js
More file actions
113 lines (109 loc) · 2.6 KB
/
webpack.config.js
File metadata and controls
113 lines (109 loc) · 2.6 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
105
106
107
108
109
110
111
112
113
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const packageInfo = require('./package.json');
const extractLess = new ExtractTextPlugin({
filename: 'css/app.css'
});
module.exports = () => {
const config = {
context: `${__dirname}/src/app`,
entry: {
'js/app.js': ['./index.js'],
'css/app.css': ['./styles/app.less']
},
output: {
filename: '[name]',
path: `${__dirname}/build/dev/${packageInfo.name}`
},
devtool: 'sourcemap',
devServer: {
//contentBase: path.join(__dirname, "dist"),
publicPath: `/${packageInfo.name}/`,
historyApiFallback: {
index: `/${packageInfo.name}/index.html`
},
stats: {
colors: true
}
},
plugins: [
extractLess,
new CopyWebpackPlugin(
[
{ from: '../../README.md', to: './README.md' },
{ from: './index.html', to: './index.html' },
{ from: './index.html', to: './404.html' },
{ from: './favicon.ico', to: './favicon.ico' }
],
{ copyUnmodified: true }
),
new webpack.DefinePlugin({
'process.env': {
// This has effect on the react lib size
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
}
})
],
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.md$/,
use: [
{
loader: 'html-loader'
},
{
loader: 'markdown-loader'
}
]
},
{
test: /\.less$/,
use: extractLess.extract({
use: [
{
loader: 'css-loader'
},
{
loader: 'less-loader'
}
]
})
},
{
test: /.*\/images\/.*/,
use: [
{
loader: 'url-loader?name=./images/[name].[ext]'
}
]
},
{
test: /\.eot$|\.svg$|\.ttf$|\.woff$|\.woff2$/,
use: [
{
loader: 'url-loader?name=./fonts/[name].[ext]'
}
]
}
]
}
};
if (process.env.NODE_ENV === 'production') {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
sourceMap: true
})
);
config.output.path = `${__dirname}/build/prod`;
}
return config;
};