This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.config.js
123 lines (118 loc) · 3.01 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* eslint-env node */
var path = require('path');
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var failPlugin = require('webpack-fail-plugin');
var DashboardPlugin = require('webpack-dashboard/plugin');
var entry = [
'./src/app.jsx'
];
var basePlugins = [
new webpack.ProvidePlugin({
'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
}),
failPlugin
];
var jsLoaders = ['babel?presets[]=react,presets[]=es2015'];
var cssLoader = ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader');
var publicPath = '/StyleGuide/static/';
var plugins = [];
if (process.env.NODE_ENV === 'production') {
plugins = basePlugins.concat([
new ExtractTextPlugin('style.css', {
allChunks: true
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
process: {env: {NODE_ENV: '"production"'}}
}),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
})
]);
} else {
entry = ['webpack-dev-server/client?http://0.0.0.0:3000',
'webpack/hot/only-dev-server'].concat(entry);
plugins = basePlugins.concat([
new webpack.DefinePlugin({
process: {env: {NODE_ENV: '"development"'}}
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new DashboardPlugin()
]);
jsLoaders = ['react-hot'].concat(jsLoaders);
cssLoader = 'style!css!sass';
publicPath = '/static/';
}
module.exports = [{
devtool: 'source-map',
entry: entry,
output: {
path: path.join(__dirname, 'dist', 'static'),
filename: 'bundle.js',
publicPath: publicPath
},
stylelint: {
configFile: path.join(__dirname, './.stylelintrc')
},
plugins: plugins,
module: {
preLoaders: [{
test: /\.s?css$/,
loader: 'stylelint',
exclude: /node_modules/
},{
test: /\.jsx?$/,
loader: 'eslint',
exclude: /node_modules/
}],
loaders: [{
test: /\.(svg|png)$/,
loader: 'file'
},{
test: /\.s?css$/,
loader: cssLoader
},{
test: /\.jsx?$/,
loaders: jsLoaders,
exclude: /node_modules/
}]
}
}, {
entry: {
all: './src/styles/all.scss',
controls: './src/styles/controls.scss',
inputs: './src/styles/inputs.scss',
panels: './src/styles/panels.scss'
},
output: {
path: path.join(__dirname, 'dist', 'static'),
filename: 'css/deleteme.js'
},
plugins: basePlugins.concat([
new ExtractTextPlugin('css/[name].css', {
allChunks: true
}),
new CopyWebpackPlugin([
{ from: 'index.html', to: '../' },
{ from: 'contents', to: '../contents' },
{ from: 'images', to: '../images' }
])
]),
sassLoader: {
outputStyle: 'expanded'
},
module: {
loaders: [{
test: /\.(svg|png)$/,
loader: 'url-loader'
},{
test: /\.s?css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader?-minimize!sass-loader')
}]
}
}];