-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.backend.config.babel.js
128 lines (126 loc) · 5.13 KB
/
webpack.backend.config.babel.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import path from 'path';
import webpack from 'webpack';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
/*** webpack plugins ***/
// Webpack plugin that emits a json file with assets paths
import AssetsPlugin from 'assets-webpack-plugin';
import htmlWebpackPlugin from 'html-webpack-plugin';
module.exports = {
entry: ['webpack/hot/dev-server', './src/backend/index.js'],
output: {
path: path.join(__dirname, 'dist/backend'),
filename: '[name].[hash].js',
publicPath: '/'
},
module: {
loaders: [
{
test: /\.js$/,
include: [path.join(__dirname, 'src/backend'), path.join(__dirname, 'src/app')],
loaders:['babel?cacheDirectory']
},
{
test:/\.less$/,
include: path.join(__dirname, 'node_modules'),
loaders: [
'style',
'css',
'less'
]
},
{
test: /\.css$/,
loaders: [
'style',
'css'
]
},
{ //排除styles目录下的全局样式,不使用css modules功能
test:/\.scss$/,
exclude: [
path.join(__dirname, 'src/app/styles'),
path.join(__dirname, 'src/backend/styles'),
],
// loader: ExtractTextPlugin.extract("style?sourceMap", "css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]!resolve-url!sass?sourceMap")
loaders: [
'style?sourceMap',
'css?modules&localIdentName=[name]_[local]',
'postcss?sourceMap',
// 'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
'resolve-url',
'sass?sourceMap=true'
]
},
{
test:/\.scss$/,
include: [
path.join(__dirname, 'src/app/styles'),
path.join(__dirname, 'src/backend/styles'),
],
loaders: [
'style',
'css',
'resolve-url',
'sass?sourceMap=true'
]
},
{
test: /\.html$/,
loader: 'raw',
},
{
test: /\.json/,
loader: 'json',
},
{
test: /.(jpeg|png|jpg)$/,
loader: 'url?limit=8192&name=img/[hash:8].[name].[ext]'
},
{test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?mimetype=image/svg+xml'},
{test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "file-loader?mimetype=application/font-woff"},
{test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "file-loader?mimetype=application/font-woff"},
{test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "file-loader?mimetype=application/octet-stream"},
{test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file-loader"},
]
},
plugins: [
new ExtractTextPlugin('style.css'),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
}),
// new webpack.HotModuleReplacementPlugin(),
new htmlWebpackPlugin({
filename: 'index.html',
template: path.join(__dirname, 'src/backend/index.html'),
inject: 'body',
}),
],
resolve: {
root: process.cwd(), // set root directory to facilitate set 'import path'
modulesDirectories: [
'node_modules'
],
// 客户端中文件指定某块的引用路径
alias: {
app: path.join(__dirname, 'src/app'),
shared: path.join(__dirname, 'src/app/components/shared'),
components: path.join(__dirname, 'src/backend/components'),
views: path.join(__dirname, 'src/backend/views'),
layouts: path.join(__dirname, 'src/backend/layouts'),
styles: path.join(__dirname, 'src/backend/styles'),
routes: path.join(__dirname, 'src/backend/routes'),
// component: dev_env_config.src_component_path,
// 'react$': path.join(dev_env_config.node_modules_path, 'react/dist/react.min.js'),
// 'react-dom$': path.join(dev_env_config.node_modules_path, 'react-dom/dist/react-dom.min.js'),
// 'redux$': path.join(dev_env_config.node_modules_path, 'redux/dist/redux.min.js'),
// 'react-redux$': path.join(dev_env_config.node_modules_path, 'react-redux/dist/react-redux.min.js'),
// 'react-router$': path.join(dev_env_config.node_modules_path, 'react-router/umd/ReactRouter.min.js'),
// 'react-router$': path.join(dev_env_config.node_modules_path, 'react-dom/dist/react-dom.min.js')
}
}
}