|
| 1 | +const webpack = require('webpack') |
| 2 | +const ExtractTextPlugin = require('extract-text-webpack-plugin') |
| 3 | +const { resolve } = require('path') |
| 4 | + |
| 5 | +const { |
| 6 | + banner, |
| 7 | + filename, |
| 8 | + version, |
| 9 | + vueLoaders |
| 10 | +} = require('./utils') |
| 11 | + |
| 12 | +const plugins = [ |
| 13 | + new webpack.DefinePlugin({ |
| 14 | + '__VERSION__': JSON.stringify(version), |
| 15 | + 'process.env.NODE_ENV': '"test"' |
| 16 | + }), |
| 17 | + new webpack.BannerPlugin({ banner, raw: true, entryOnly: true }), |
| 18 | + new ExtractTextPlugin({ |
| 19 | + filename: `${filename}.css`, |
| 20 | + // Don't extract css in test mode |
| 21 | + disable: /^(common|test)$/.test(process.env.NODE_ENV) |
| 22 | + }) |
| 23 | +] |
| 24 | + |
| 25 | +module.exports = { |
| 26 | + output: { |
| 27 | + path: resolve(__dirname, '../dist'), |
| 28 | + filename: `${filename}.common.js` |
| 29 | + }, |
| 30 | + entry: ['velocityjs', 'hammerjs', './src/index.js'], |
| 31 | + resolve: { |
| 32 | + extensions: ['.js', '.vue', '.jsx', 'css'], |
| 33 | + alias: { |
| 34 | + 'src': resolve(__dirname, '../src') |
| 35 | + } |
| 36 | + }, |
| 37 | + plugins: [ |
| 38 | + new webpack.ProvidePlugin({ |
| 39 | + $: "jquery", |
| 40 | + jQuery: "jquery" |
| 41 | + }) |
| 42 | + ], |
| 43 | + module: { |
| 44 | + rules: [ |
| 45 | + { |
| 46 | + test: /.jsx?$/, |
| 47 | + use: 'babel-loader', |
| 48 | + include: [ |
| 49 | + resolve(__dirname, '../node_modules/@material'), |
| 50 | + resolve(__dirname, '../src'), |
| 51 | + resolve(__dirname, '../test') |
| 52 | + ] |
| 53 | + }, |
| 54 | + { |
| 55 | + test: /\.vue$/, |
| 56 | + loader: 'vue-loader', |
| 57 | + options: { |
| 58 | + loaders: vueLoaders, |
| 59 | + postcss: [require('postcss-cssnext')()], |
| 60 | + optimizeSSR: false |
| 61 | + } |
| 62 | + }, |
| 63 | + { |
| 64 | + test: /\.scss$/, |
| 65 | + loaders: ["style", "css", "sass"], |
| 66 | + include: resolve('assetsPath') |
| 67 | + }, |
| 68 | + ] |
| 69 | + }, |
| 70 | + node: { |
| 71 | + fs: 'empty', |
| 72 | + net: 'empty' |
| 73 | + }, |
| 74 | + plugins |
| 75 | +} |
0 commit comments