forked from chvin/react-tetris
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathw.config.js
More file actions
114 lines (104 loc) · 2.5 KB
/
Copy pathw.config.js
File metadata and controls
114 lines (104 loc) · 2.5 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
114
var webpack = require('webpack');
var OpenBrowserPlugin = require('open-browser-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var precss = require('precss');
var autoprefixer = require('autoprefixer');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var version = require('./package.json').version;
var entry = __dirname + '/src/index.js';
var output = {
filename: 'page/[name]/index.js',
chunkFilename: 'chunk/[name].[chunkhash:5].chunk.js',
};
// source-map
var devtool = 'source-map';
// eslint
var eslint = {
configFile: __dirname + '/.eslintrc.js',
}
// loader
var loaders = [
{
test: /\.(json)$/,
exclude: /node_modules/,
loader: 'json',
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel!eslint-loader',
},
{
test: /\.(?:png|jpg|gif)$/,
loader: 'url?limit=8192',
},
{
test: /\.less/,
loader: ExtractTextPlugin.extract('style', 'css?modules&localIdentName=[hash:base64:4]!postcss!less'),
}
];
// dev plugin
var devPlugins = [
new CopyWebpackPlugin([
{ from: './src/resource/music/music.mp3' },
{ from: './src/resource/css/loader.css' },
]),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new OpenBrowserPlugin({
url: 'http://127.0.0.1:8080/'
}),
// css
new ExtractTextPlugin('css.css', {
allChunks: true
}),
]
// production plugin
var productionPlugins = [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
}),
new CopyWebpackPlugin([
{ from: './src/resource/music/music.mp3' },
{ from: './src/resource/css/loader.css' },
]),
// HTML
new HtmlWebpackPlugin({
template: __dirname + '/server/index.tmpl.html'
}),
// JS
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}}
),
// css
new ExtractTextPlugin('css-' + version + '.css', {
allChunks: true
}),
];
// dev server
var devServer = {
contentBase: './server',
colors: true,
historyApiFallback: false,
port: 8080, // defaults to "8080"
hot: true, // Hot Module Replacement
inline: true, // Livereload
host: '0.0.0.0',
disableHostCheck: true
};
module.exports = {
entry: entry,
devtool: devtool,
output: output,
loaders: loaders,
devPlugins: devPlugins,
productionPlugins: productionPlugins,
devServer: devServer,
postcss: function () {
return [precss, autoprefixer];
},
version: version
};