2018-05-21 15:26:46 +08:00
|
|
|
const path = require('path');
|
|
|
|
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
|
2019-01-23 11:34:19 +08:00
|
|
|
const VueLoaderPlugin = require('vue-loader/lib/plugin');
|
2018-05-21 15:26:46 +08:00
|
|
|
|
|
|
|
const config = require('./config');
|
|
|
|
|
|
|
|
const webpackConfig = {
|
2019-01-23 11:34:19 +08:00
|
|
|
mode: 'development',
|
2018-05-21 15:26:46 +08:00
|
|
|
entry: {
|
|
|
|
app: ['./src/index.js']
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: path.resolve(process.cwd(), './dist'),
|
|
|
|
publicPath: '/dist/',
|
|
|
|
filename: '[name].js',
|
|
|
|
chunkFilename: '[id].js'
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.js', '.vue', '.json'],
|
|
|
|
alias: Object.assign(config.alias, {
|
|
|
|
'vue$': 'vue/dist/vue.common.js'
|
|
|
|
}),
|
|
|
|
modules: ['node_modules']
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(jsx?|babel|es6)$/,
|
|
|
|
include: process.cwd(),
|
|
|
|
exclude: config.jsexclude,
|
|
|
|
loader: 'babel-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.vue$/,
|
|
|
|
loader: 'vue-loader',
|
|
|
|
options: {
|
2019-01-23 11:34:19 +08:00
|
|
|
compilerOptions: {
|
|
|
|
preserveWhitespace: false
|
|
|
|
}
|
2018-05-21 15:26:46 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
2019-02-26 16:23:26 +08:00
|
|
|
loaders: ['style-loader', 'css-loader']
|
2018-05-21 15:26:46 +08:00
|
|
|
},
|
|
|
|
{
|
2019-01-23 11:34:19 +08:00
|
|
|
test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
|
2018-05-21 15:26:46 +08:00
|
|
|
loader: 'url-loader',
|
|
|
|
query: {
|
|
|
|
limit: 10000,
|
|
|
|
name: path.posix.join('static', '[name].[hash:7].[ext]')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
2019-01-23 11:34:19 +08:00
|
|
|
new VueLoaderPlugin()
|
2018-05-21 15:26:46 +08:00
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!process.env.CI_ENV) {
|
|
|
|
webpackConfig.plugins.push(
|
|
|
|
new ProgressBarPlugin()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = webpackConfig;
|