This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
77 lines (73 loc) · 1.98 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const webpack = require('webpack');
const path = require('path');
const ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const OptimiseCssAssets = require('optimize-css-assets-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const rimraf = require('rimraf');
let config = {
entry: './resources/index.js',
output: {
path: path.resolve(__dirname, './www'),
filename: 'main.js'
},
module: {
rules: [
{
test: /\.js$/, // files ending with .js
exclude: /node_modules/, // exclude the node_modules directory
loader: "babel-loader", // use this (babel-core) loader
query: {
presets: ['es2015']
}
},
{
test: /\.(css|scss)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: ExtractTextWebpackPlugin.extract({
use: ['css-loader?url=false', 'sass-loader'],
fallback: 'style-loader'
})
},
{
test: /\.(ttf|eot|svg|gif|png|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [{
loader: 'file-loader'
}]
}
]
},
plugins: [
new ExtractTextWebpackPlugin('assets/scss/style.css'),
new CopyWebpackPlugin([
{from: './resources/assets', to: './assets'}
], {
ignore: [
'scss/*',
],
copyUnmodified: true
})
],
devServer: {
contentBase: path.resolve(__dirname, './www'),
historyApiFallback: true,
inline: true,
open: true
},
devtool: 'eval-source-map',
resolve: {
extensions: ['*', '.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js' // 'vue/dist/vue.common.js' for webpack 1
}
}
};
if (process.env.NODE_ENV === 'production') {
rimraf('./www/assets', function () {
console.log('assets folder removed');
});
config.plugins.push(
new webpack.optimize.UglifyJsPlugin(), // call the uglify plugin
new OptimiseCssAssets()
);
}
module.exports = config;