-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
75 lines (74 loc) · 3.09 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
/* eslint-env node */
var fs = require("fs");
var path = require("path");
var webpack = require("webpack");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: "./index.jsx",
output: {
path: "dist/Resources",
filename: "[name].[hash:8].js",
publicPath: "/Resources/"
},
resolve: {
extensions: ["", ".js", ".jsx"]
},
module: {
loaders: [
{ test: /\.(sc|sa|c)ss$/, loader: ExtractTextPlugin.extract("style", "css?sourceMap&importLoaders=1&modules&camelCase&localIdentName=🌚[emoji]!postcss!sass") },
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "file?limit=8192&name=Asserts/[hash:hex:6].[ext]&minetype=application/font-woff" },
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "file?limit=8192&name=Asserts/[hash:hex:6].[ext]&minetype=application/font-woff" },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "file?limit=8192&name=Asserts/[hash:hex:6].[ext]&minetype=application/octet-stream" },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file?limit=8192&name=Asserts/[hash:hex:6].[ext]" },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "file?limit=8192&name=Asserts/[hash:hex:6].[ext]&minetype=image/svg+xml" },
{ test: /\.(jpe?g|gif|png)$/, loader: "file?limit=8192&name=Asserts/[hash:hex:6].[ext]" },
{
test: /\.js|jsx$/,
exclude: /node_modules/,
loader: "babel",
query: {
presets: ["es2015", "react"],
plugins: [
["import", [
{ libraryName: "react-toolbox", style: "sass" },
{ libraryName: "react-router", camel2DashComponentName: false },
]], "add-module-exports", "transform-runtime"
]
}
}
]
},
sassLoader: {
data: "@import \"" + path.resolve(__dirname, "css/_theme.scss") + "\";"
},
postcss: function () {
return [
require("autoprefixer")({
browsers: ["ie >= 9", "> 2%", "last 1 version"]
})
];
},
plugins: [
new ExtractTextPlugin("[name].[hash:8].css"),
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("production")
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
comments: false,
sourceMap: false
}),
function () {
this.plugin("done", function (stats) {
let hash = stats.hash.substr(0, 8);
let out = fs.readFileSync(path.join(__dirname, "index.html"), "utf8");
out = out.replace(new RegExp("main.js", "g"), `main.${hash}.js`);
out = out.replace(new RegExp("main.css", "g"), `main.${hash}.css`);
fs.writeFileSync(path.join(__dirname, "dist/index.html"), out);
});
}
]
};