2017-07-04 03:28:56 +00:00
|
|
|
'use strict';
|
|
|
|
process.env.NODE_ENV = 'development';
|
2017-09-14 22:49:15 +00:00
|
|
|
const path = require('path');
|
2017-07-04 03:28:56 +00:00
|
|
|
const webpack = require('webpack');
|
|
|
|
const base = require('./webpack.base');
|
|
|
|
const FriendlyErrors = require('friendly-errors-webpack-plugin');
|
2017-12-30 20:29:04 +00:00
|
|
|
const AutoDllPlugin = require('autodll-webpack-plugin');
|
|
|
|
const config = require('./config');
|
|
|
|
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
|
|
|
|
const threadLoader = require('thread-loader');
|
2017-04-12 04:59:58 +00:00
|
|
|
|
2017-12-30 20:29:04 +00:00
|
|
|
const fullSourceMap = process.env.SLOW_BUILD_SPEED;
|
|
|
|
if (fullSourceMap) {
|
|
|
|
base.devtool = fullSourceMap ? 'source-map' : 'cheap-module-eval-source-map';
|
2017-09-13 17:56:20 +00:00
|
|
|
|
2017-12-30 20:29:04 +00:00
|
|
|
threadLoader.warmup(
|
|
|
|
{
|
|
|
|
// pool options, like passed to loader options
|
|
|
|
// must match loader options to boot the correct pool
|
|
|
|
happyPackMode: true,
|
|
|
|
logLevel: 'info'
|
|
|
|
},
|
|
|
|
[
|
|
|
|
// modules to load
|
|
|
|
// can be any module, i. e.
|
|
|
|
'ts-loader'
|
|
|
|
]
|
|
|
|
);
|
|
|
|
base.module.rules[0].use.unshift({
|
|
|
|
loader: 'thread-loader',
|
|
|
|
options: {
|
|
|
|
workers: 4
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
base.performance = { hints: false };
|
|
|
|
|
|
|
|
base.module.rules.push(
|
2017-07-04 03:28:56 +00:00
|
|
|
{
|
|
|
|
test: /\.css$/,
|
2017-12-30 20:29:04 +00:00
|
|
|
include: path.resolve(__dirname, '../common/vendor'),
|
|
|
|
use: ['style-loader', 'css-loader']
|
2017-07-04 03:28:56 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
2017-12-30 20:29:04 +00:00
|
|
|
include: ['components', 'containers', 'sass']
|
|
|
|
.map(dir => path.resolve(__dirname, `../common/${dir}`))
|
|
|
|
.concat([path.resolve(__dirname, '../node_modules')]),
|
|
|
|
|
|
|
|
exclude: /node_modules(?!\/font-awesome)/,
|
|
|
|
use: ['style-loader', 'css-loader', 'sass-loader']
|
2017-07-04 03:28:56 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.less$/,
|
2017-12-30 20:29:04 +00:00
|
|
|
include: path.resolve(__dirname, '../common/assets/styles'),
|
|
|
|
use: ['style-loader', 'css-loader', 'less-loader']
|
2017-07-04 03:28:56 +00:00
|
|
|
}
|
|
|
|
);
|
2017-04-14 07:12:20 +00:00
|
|
|
|
2017-04-12 04:59:58 +00:00
|
|
|
base.plugins.push(
|
2017-12-30 20:29:04 +00:00
|
|
|
new AutoDllPlugin({
|
|
|
|
inject: true, // will inject the DLL bundles to index.html
|
|
|
|
filename: '[name]_[hash].js',
|
|
|
|
debug: true,
|
|
|
|
context: path.join(__dirname, '..'),
|
|
|
|
entry: {
|
|
|
|
vendor: [...config.vendor, 'babel-polyfill', 'bootstrap-sass', 'font-awesome']
|
|
|
|
}
|
2017-09-14 22:49:15 +00:00
|
|
|
}),
|
2017-12-30 20:29:04 +00:00
|
|
|
new HardSourceWebpackPlugin({
|
|
|
|
environmentHash: {
|
|
|
|
root: process.cwd(),
|
|
|
|
directories: ['webpack_config'],
|
|
|
|
files: ['package.json']
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
2017-07-04 03:28:56 +00:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.NODE_ENV': JSON.stringify('development')
|
|
|
|
}),
|
|
|
|
new webpack.HotModuleReplacementPlugin(),
|
|
|
|
new webpack.NoEmitOnErrorsPlugin(),
|
|
|
|
new FriendlyErrors()
|
|
|
|
);
|
2017-04-12 04:59:58 +00:00
|
|
|
|
2017-07-04 03:28:56 +00:00
|
|
|
module.exports = base;
|