vant/test/unit/get-webpack-conf.js
Yao 2b5d306628 修改 unit test 的配置 (#10)
* change require vue to Vue && waterfall.md

* use vue in amd & commonjs, use Vue in root

* change webpack config

* fix some config
2017-04-25 18:10:05 +08:00

117 lines
2.7 KiB
JavaScript

const path = require('path');
const webpack = require('webpack');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const getPostcssPlugin = require('../../build/utils/postcss_pipe');
const webpackConfig = {
output: {
path: path.resolve(process.cwd(), 'dist'),
publicPath: '/dist/',
filename: '[name].js',
chunkFilename: '[id].js',
libraryTarget: 'umd'
},
plugins: [
new ProgressBarPlugin(),
new webpack.LoaderOptionsPlugin({
minimize: true,
options: {
postcss: getPostcssPlugin,
babel: {
presets: ['es2015'],
plugins: ['transform-runtime', 'transform-vue-jsx']
},
vue: {
autoprefixer: false,
preserveWhitespace: false,
postcss: getPostcssPlugin
}
}
})
],
resolve: {
modules: [
path.resolve(process.cwd(), 'node_modules'),
'node_modules'
],
extensions: ['.js', '.json', '.vue'],
alias: {
src: path.resolve(process.cwd(), 'src'),
packages: path.resolve(process.cwd(), 'packages'),
examples: path.resolve(process.cwd(), 'examples'),
vue$: 'vue/dist/vue.common.js'
}
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
exclude: /node_modules|vue-router\/|vue-loader\/|vue-hot-reload-api\/|docs|test|src\/index/,
use: ['isparta-loader']
},
{
test: /\.js$/,
exclude: /node_modules|vue-router\/|vue-loader\/|vue-hot-reload-api\//,
use: ['babel-loader']
},
{
test: /\.(css|pcss)$/,
use: [
'style-loader',
'css-loader',
'postcss-loader'
]
},
{
test: /\.(gif|png|jpe?g)(\?\S*)?$/,
use: [{
loader: 'url-loader',
options: {
query: {
limit: 10000,
name: 'static/[name].[hash:7].[ext]'
}
}
}]
},
{
test: /test\/unit\/components\/.*\.vue$/,
use: [{
loader: 'vue-loader',
options: {
loaders: {
css: [
'style-loader',
'css-loader',
'postcss-loader'
]
}
}
}]
},
{
test: /packages\/.*\.vue$/,
use: [{
loader: 'vue-loader',
options: {
loaders: {
css: [
'style-loader',
'css-loader',
'postcss-loader'
],
js: [
'isparta-loader'
]
}
}
}]
}
]
},
devtool: '#inline-source-map'
};
module.exports = webpackConfig;