-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
97 lines (93 loc) · 2.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
'use strict';
const webpack = require('webpack');
const path = require('path');
const autoprefixer = require('autoprefixer');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ENV = process.env.NODE_ENV;
const isTest = ENV === 'test';
const isProd = ENV === 'production';
const isDev = ENV === 'development' || ENV === '';
const config = {
entry: {
vendor: path.join(__dirname, 'src/vendor.ts'),
main: path.join(__dirname, 'src/main.ts'),
},
output: {
path: `${__dirname}/dist`,
filename: '[name].js',
publicPath: '/'
},
devtool: 'cheap-module-eval-source-map',
debug: isDev,
devServer: {
contentBase: './dist',
// 'content-base': './dist'
},
// externals,
resolve: {
cache: !isTest,
root: path.join(__dirname, 'src'),
extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'],
alias: {
'techfeed': path.resolve(__dirname, '..')
}
},
module: {
loaders: [
{
test: /\.ts$/,
loader: 'awesome-typescript'
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.css$/,
loaders: ['raw', 'css', 'postcss']
},
{
test: /\.scss$/,
loaders: ['raw', 'sass?sourceMap'],
exclude: /node_modules/
},
{
test: /\.html$/,
loaders: ['raw'],
exclude: ['src/index.html']
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
}),
new webpack.DefinePlugin({ENV}),
new HtmlWebpackPlugin({
template: 'src/index.html',
inject: true
}),
new CopyWebpackPlugin([
{
from: 'src/**/*.html',
to: 'dist'
}
]),
],
postcss: [
autoprefixer({
browsers: ['last 2 version']
})
]
};
// プロダクション環境限定の調整
if (isProd) {
config.plugins.push(
new webpack.NoErrorsPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
);
}
module.exports = config;