-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.babel.js
114 lines (100 loc) · 2.84 KB
/
webpack.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
import path from 'path';
import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import WriteFilePlugin from 'write-file-webpack-plugin';
import StaticSiteGenerator from './build/plugins/static-site-generator';
import Autoprefixer from 'autoprefixer';
import SassJSONImporter from '../../sass-json-importer/sass-json-importer/dist/synergy-sass-importer';
/**
* @param {*} env
*/
export default function(env) {
const isDevServer = path.basename(require.main.filename) === 'webpack-dev-server.js';
// const isDevServer = path.basename(require.main.filename) === 'server.js';
const isNonProd = isDevServer || env && env.build === 'development';
const staticBuild = env && env.static;
let plugins = [
new webpack.DefinePlugin({
'process.env': {
ONE_NEXUS: true,
SYNERGY: true,
// NODE_ENV: JSON.stringify(isDevServer ? 'development' : 'production'),
// APP_ENV : JSON.stringify(staticBuild ? 'node' : 'web')
}
}),
// new webpack.ProvidePlugin({
// 'React': 'react'
// })
];
// if (isDevServer) {
// plugins.push(
// new WriteFilePlugin(),
// new webpack.HotModuleReplacementPlugin()
// );
// }
// plugins.push(staticBuild ? StaticSiteGenerator : new HtmlWebpackPlugin({
// template: 'src/views/core.jsx',
// inject: false
// }));
return {
entry: [
'./src/entry.js',
// './src/static.js'
],
mode: env.build,
resolve: {
extensions: ['.js', '.jsx', '.json', '.jss']
},
output: {
filename: 'app.js',
// path: path.resolve(__dirname, '/'),
// publicPath: '/',
// libraryTarget: 'umd'
},
devServer: {
// contentBase: './',
// publicPath: '/',
// hot: true,
port: 3000
},
// externals: {
// 'react': 'React',
// 'react-dom': 'ReactDOM'
// },
plugins,
module: {
rules: [
{
test: /\.(js|jsx|jss)$/,
// exclude: (MODULE) => ~MODULE.indexOf('/node_modules/') && !(~MODULE.indexOf('/@onenexus/')),
use: 'babel-loader'
},
{
test: /\.scss$/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader'},
{loader: 'postcss-loader', options: {
sourceMap: true,
plugins: () => [Autoprefixer]
}},
{loader: 'sass-loader', options: {
sassOptions: {
sourceMap: true,
importer: SassJSONImporter,
outputStyle: 'expanded'
}
}}
]
},
{
test: /\.css$/,
include: /node_modules/,
loaders: ['style-loader', 'css-loader']
}
]
},
stats: { colors: true },
devtool: isNonProd ? 'source-map' : false
}
}