2018-07-29 15:31:54 +08:00
|
|
|
const VueLoaderPlugin = require('vue-loader/lib/plugin');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2018-08-04 09:12:04 +08:00
|
|
|
const UglifyJsWebpackPlugin = require('uglifyjs-webpack-plugin');
|
2018-08-04 09:02:45 +08:00
|
|
|
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
2018-07-29 15:31:54 +08:00
|
|
|
const WebpackBar = require('webpackbar');
|
|
|
|
|
|
|
|
const devMode = !process.argv.includes('-p');
|
|
|
|
|
2018-07-29 18:56:07 +08:00
|
|
|
module.exports = [{
|
2018-07-29 15:31:54 +08:00
|
|
|
entry: {
|
|
|
|
index: './resources/assets/src/index.js',
|
|
|
|
polyfill: './resources/assets/src/js/polyfill.js',
|
|
|
|
style: [
|
|
|
|
'bootstrap/dist/css/bootstrap.min.css',
|
|
|
|
'admin-lte/dist/css/AdminLTE.min.css',
|
|
|
|
'bootstrap-fileinput/css/fileinput.min.css',
|
|
|
|
'font-awesome/css/font-awesome.min.css',
|
|
|
|
'icheck/skins/square/blue.css',
|
|
|
|
'toastr/build/toastr.min.css',
|
2018-08-04 10:22:16 +08:00
|
|
|
'sweetalert2/dist/sweetalert2.min.css',
|
2018-07-30 11:24:36 +08:00
|
|
|
'./resources/assets/src/stylus/common.styl',
|
2018-08-07 09:25:20 +08:00
|
|
|
],
|
|
|
|
home: './resources/assets/src/stylus/home.styl'
|
2018-07-29 15:31:54 +08:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: __dirname + '/public',
|
|
|
|
filename: '[name].js',
|
|
|
|
chunkFilename: devMode
|
|
|
|
? '[id].js'
|
|
|
|
: '[id].[chunkhash:7].js'
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
2018-08-02 23:02:13 +08:00
|
|
|
use: [
|
|
|
|
'cache-loader',
|
|
|
|
'babel-loader'
|
|
|
|
]
|
2018-07-29 15:31:54 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.vue$/,
|
2018-08-02 23:02:13 +08:00
|
|
|
use: [
|
|
|
|
'cache-loader',
|
|
|
|
'vue-loader'
|
|
|
|
]
|
2018-07-29 15:31:54 +08:00
|
|
|
},
|
|
|
|
{
|
2018-07-30 09:45:37 +08:00
|
|
|
test: /\.(css|styl(us)?)$/,
|
2018-07-29 15:31:54 +08:00
|
|
|
exclude: /node_modules/,
|
|
|
|
use: [
|
2018-07-30 09:45:37 +08:00
|
|
|
'vue-style-loader',
|
2018-07-29 15:31:54 +08:00
|
|
|
{ loader: 'css-loader', options: { importLoaders: 2 } },
|
|
|
|
'postcss-loader',
|
|
|
|
'stylus-loader'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /node_modules.*\.css$/,
|
2018-08-04 10:22:16 +08:00
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
{ loader: 'css-loader', options: { importLoaders: 1 } },
|
|
|
|
'csso-loader?-comments',
|
|
|
|
]
|
2018-07-29 15:31:54 +08:00
|
|
|
},
|
2018-07-30 11:24:36 +08:00
|
|
|
{
|
2018-08-07 09:25:20 +08:00
|
|
|
test: /(common|home)\.styl$/,
|
2018-07-30 11:24:36 +08:00
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
2018-08-04 10:22:16 +08:00
|
|
|
{ loader: 'css-loader', options: { importLoaders: 3 } },
|
|
|
|
'csso-loader',
|
2018-07-30 11:24:36 +08:00
|
|
|
'postcss-loader',
|
|
|
|
'stylus-loader'
|
|
|
|
]
|
|
|
|
},
|
2018-07-29 15:31:54 +08:00
|
|
|
{
|
2018-08-03 10:35:06 +08:00
|
|
|
test: /\.(png|jpg|gif)$/,
|
2018-07-29 15:31:54 +08:00
|
|
|
loader: 'url-loader',
|
|
|
|
options: {
|
|
|
|
limit: 8192
|
|
|
|
}
|
2018-08-03 10:35:06 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(svg|woff2?|eot|ttf)$/,
|
|
|
|
loader: 'file-loader'
|
2018-07-29 15:31:54 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
noParse: /^(vue|jquery)$/
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new VueLoaderPlugin(),
|
|
|
|
new WebpackBar(),
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: '[name].css',
|
|
|
|
chunkFilename: '[id].css'
|
|
|
|
}),
|
|
|
|
new CopyWebpackPlugin([
|
|
|
|
{
|
|
|
|
from: 'node_modules/admin-lte/dist/css/skins/skin-*.min.css',
|
|
|
|
to: 'skins',
|
|
|
|
flatten: true
|
|
|
|
},
|
|
|
|
]),
|
2018-08-04 09:02:45 +08:00
|
|
|
new BundleAnalyzerPlugin({
|
|
|
|
openAnalyzer: false,
|
|
|
|
analyzerMode: devMode ? 'server' : 'static'
|
|
|
|
}),
|
2018-07-29 15:31:54 +08:00
|
|
|
],
|
2018-08-02 23:02:13 +08:00
|
|
|
optimization: {
|
|
|
|
minimizer: [
|
2018-08-04 09:12:04 +08:00
|
|
|
new UglifyJsWebpackPlugin({
|
|
|
|
parallel: true,
|
2018-08-02 23:02:13 +08:00
|
|
|
cache: true,
|
2018-08-04 09:12:04 +08:00
|
|
|
sourceMap: false,
|
|
|
|
extractComments: {
|
|
|
|
filename: 'LICENSES'
|
|
|
|
},
|
|
|
|
uglifyOptions: {
|
|
|
|
output: {
|
|
|
|
comments: /^\**!|@preserve|@license|@cc_on/
|
|
|
|
}
|
|
|
|
}
|
2018-08-02 23:02:13 +08:00
|
|
|
})
|
|
|
|
]
|
|
|
|
},
|
2018-07-29 15:31:54 +08:00
|
|
|
resolve: {
|
|
|
|
extensions: ['.js', '.vue', '.json']
|
|
|
|
},
|
|
|
|
devtool: devMode ? 'cheap-module-eval-source-map' : false,
|
|
|
|
stats: 'errors-only'
|
2018-07-29 18:56:07 +08:00
|
|
|
}, {
|
|
|
|
entry: {
|
|
|
|
en: './resources/lang/en/front-end.yml',
|
|
|
|
zh_CN: './resources/lang/zh_CN/front-end.yml',
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: __dirname + '/public/langs/',
|
|
|
|
filename: '[name].js',
|
|
|
|
library: '__bs_i18n__'
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.yml$/,
|
|
|
|
use: [
|
|
|
|
'json-loader',
|
|
|
|
'yaml-loader'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
stats: 'errors-only'
|
|
|
|
}];
|