-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
106 lines (104 loc) · 2.57 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
const env = process.env.MIX_ENV === "prod" ? "production" : "development";
const Webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const Autoprefixer = require("autoprefixer");
const plugins = {
production: [
new Webpack.optimize.UglifyJsPlugin({
compress: {warnings: false}
})
],
development: []
}
module.exports = {
devtool: 'source-map',
entry: [
"./web/static/js/index.js",
"./web/static/styles/index.less"
],
output: {
path: "./priv/static",
filename: "js/app.js",
publicPath: "/",
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel",
query: {
plugins: ["transform-decorators-legacy"],
presets: ["react", "es2015", "stage-2", "stage-0"],
}
}, {
test: /\.less$/,
loader: ExtractTextPlugin.extract("style", "css?localIdentName=[hash:base64]!postcss!less")
}, {
test: /\.png$/,
loader: "url?" + [
"limit=100000",
"mimetype=image/png"
].join("&"),
}, {
test: /\.gif$/,
loader: "url?" + [
"limit=100000",
"mimetype=image/gif"
].join("&"),
}, {
test: /\.jpg$/,
loader: "file?name=images/[name].[ext]",
}, {
test: /\.(woff|woff2)$/,
loader: "url?" + [
"limit=10000",
"mimetype=application/font-woff",
"name=fonts/[name].[ext]"
].join("&"),
}, {
test: /\.ttf$/,
loader: "url?" + [
"limit=10000",
"mimetype=application/octet-stream",
"name=fonts/[name].[ext]"
].join("&"),
}, {
test: /\.eot$/,
loader: "url?" + [
"limit=10000",
"name=fonts/[name].[ext]"
].join("&"),
}, {
test: /\.svg$/,
loader: "url?" + [
"limit=10000",
"mimetype=image/svg+xml",
"name=images/[name].[ext]"
].join("&"),
}],
},
postcss: [
Autoprefixer({
browsers: ["last 2 versions"]
})
],
resolve: {
extensions: ["", ".js", ".less", ".css"],
modulesDirectories: ["node_modules", __dirname + "/web/static/js"],
alias: {
styles: __dirname + "/web/static/styles"
}
},
plugins: [
// Important to keep React file size down
new Webpack.DefinePlugin({
"process.env": {
"NODE_ENV": JSON.stringify(env),
},
}),
new Webpack.optimize.DedupePlugin(),
new ExtractTextPlugin("css/app.css"),
new CopyPlugin([{from: "./web/static/assets"}])
].concat(plugins[env])
};