forked from anthonydugois/polynom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
71 lines (59 loc) · 1.53 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
import path from "path"
import webpack from "webpack"
import ExtractTextPlugin from "extract-text-webpack-plugin"
import variables, { defineVariables } from "./variables"
defineVariables()
export default {
entry: [
...__DEV__ && [
`webpack-dev-server/client?${ __SERVER_URL__ }`,
"webpack/hot/dev-server",
],
"./src/index.js",
],
output: {
path: path.join(__dirname, __OUTPUT_DIR__),
...__DEV__ && { publicPath: `${ __SERVER_URL__ }/${ __OUTPUT_DIR__ }/` },
filename: "bundle.js",
},
resolve: {
extensions: ["", ".js", ".css"],
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loaders: ["babel", "eslint"],
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract("style", "css!postcss"),
},
// workaround to import Snap.svg as a module
{
test: require.resolve("snapsvg"),
loader: "imports?this=>window,fix=>module.exports=0",
},
],
},
plugins: [
new webpack.DefinePlugin(variables),
new ExtractTextPlugin("styles.css", { disable: __DEV__ }),
...__PROD__ && [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
})
],
...__DEV__ && [
new webpack.HotModuleReplacementPlugin(),
],
],
postcss: (webpack) => [
require("stylelint"),
require("postcss-import")({ addDependencyTo: webpack }),
require("postcss-url"),
require("postcss-cssnext"),
],
}