forked from lian-yue/lianyue-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
93 lines (77 loc) · 2.87 KB
/
webpack.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
"strict mode"
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require("extract-text-webpack-plugin")
const precss = require('precss')
const autoprefixer = require('autoprefixer')
const packageInfo = require('./package.json')
var version = packageInfo.version.split('.');
version[version.length -1] = parseInt(version[version.length -1]) + 1;
packageInfo.version = version.join('.');
module.exports = {
entry: {
bundle: [
path.join(__dirname, 'app/views/html/client.js'),
path.join(__dirname, 'app/views/html/style/index.js')
],
ie: [
path.join(__dirname, 'node_modules/html5shiv/src/html5shiv.js'),
path.join(__dirname, 'app/views/html/ie.js'),
],
},
output: {
path: path.join(__dirname, 'public/assets/html/'),
publicPath: '/assets/html/',
filename: "[name].js",
chunkFilename: "[chunkhash:8].[name].chunk.js",
},
resolve: {
root: path.join(__dirname, 'node_modules'),
alias: {
},
extensions: ['', '.js', '.jsx', '.json', '.css', '.less', '.sass', '.scss', '.styl'],
},
resolveLoader: {
},
devServer: {
hot: true,
inline: true
},
module: {
loaders: [
{test: require.resolve('react'), loader: 'expose?React'},
{test: /\.(js|jsx)$/, loader: 'babel', exclude: /node_modules/},
{test: /\.styl$/, loader: ExtractTextPlugin.extract('style', 'css!postcss!stylus')},
{test: /\.sass$/, loader: ExtractTextPlugin.extract('style', 'css!postcss!sass')},
{test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css!postcss!sass')},
{test: /\.less$/, loader: ExtractTextPlugin.extract('style', 'css!postcss!less')},
{test: /\.css$/, loader: ExtractTextPlugin.extract("style", "css!postcss")},
{test: /\.(gif|jpg|png)\??.*$/, loader: 'url-loader?limit=4096&name=images/[name].[ext]?v=[hash:8]'},
{test: /\.(woff|svg|eot|ttf|woff2|woff)\??.*$/, loader: 'url-loader?limit=4096&name=fonts/[name].[ext]?v=[hash:8]'},
]
},
babel: {
presets: ['es2015', 'react', 'stage-0'],
plugins: ['transform-runtime', 'add-module-exports'],
},
postcss: function () {
return [precss, autoprefixer];
},
plugins: [
new ExtractTextPlugin("[name].css"),
new webpack.BannerPlugin("Name: "+packageInfo.name+"\nVersion: "+ packageInfo.version +"\nAuthor: "+ packageInfo.author +"\nDescription: "+ packageInfo.description +""),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
},
'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'__ENV__': JSON.stringify(process.env.NODE_ENV),
'process.version': JSON.stringify(packageInfo.version),
__SERVER__: false,
}),
],
devtool: '#eval-source-map'
};
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
}