-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
75 lines (71 loc) · 2.51 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
"use strict";
const path = require("path");
const webpack = require("webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const UnminifiedWebpackPlugin = require("unminified-webpack-plugin");
const OptimizeCssAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const isProduction = process.env.NODE_ENV === "production";
module.exports = {
entry: {
app: "./src/main.ts"
},
output: {
path: path.resolve(__dirname, "./public"),
publicPath: "",
filename: "main.min.js"
},
resolve: {
extensions: ['.ts', '.js', '.vue', '.json'],
},
module: {
rules: [
{ test: /\.vue$/, loader: 'vue-loader',
options: {
loaders: {
ts: 'awesome-typescript-loader',
tsx: 'babel-loader!awesome-typescript-loader',
}
}
},
{ test: /\.tsx?$/, loader: 'awesome-typescript-loader', options: { appendTsSuffixTo: [/TS\.vue$/] } },
{ test: /\.json/, loader: "json-loader" },
{ test: /\.svg/, loader: "svg-url-loader" },
{ test: /\.(png|jpg|jpeg|gif)$/, loader: "file-loader?name=[name]-[hash:6].[ext]" },
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: "style-loader",
loader: "css-loader!postcss-loader",
publicPath: ""
})
}]
},
devtool: "#eval-source-map",
plugins: [
new webpack.LoaderOptionsPlugin({
vue: {
postcss: [
require("postcss-cssnext")()
]
}
}),
new ExtractTextPlugin(isProduction ? "bi-[hash:6].min.css" : "bi.min.css"),
new HtmlWebpackPlugin({
filename: "index.html",
template: "src/index.html"
}),
new CopyWebpackPlugin([
{ from: path.join(__dirname, "/src/policy.html") },
{ from: path.join(__dirname, "/src/img/bi.png"), to: path.join(__dirname, "/public/img/bi.png") }
])
]
};
if (process.env.NODE_ENV === "production") {
module.exports.output.filename = "main-[hash:6].min.js";
module.exports.devtool = false;
module.exports.plugins = (module.exports.plugins || []).concat([
new OptimizeCssAssetsPlugin()
]);
}