This repository has been archived by the owner on Feb 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
71 lines (64 loc) · 2.08 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
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MinifyPlugin = require("babel-minify-webpack-plugin");
const CleanWebpackPlugin = require('clean-webpack-plugin')
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin();
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: './assets/layout.twig',
filename: '../templates/layout.twig',
inject: 'body'
});
const extractSass = new ExtractTextPlugin({
filename: "[name].[contenthash:base64:5].css"
});
let pathsToClean = [
'public/*.js',
'public/*.css'
];
var BUILD_DIR = path.resolve(__dirname, './public');
var APP_DIR = path.resolve(__dirname, './assets');
var config = {
entry: [APP_DIR + '/js/index.js', APP_DIR + '/scss/main.scss'],
output: {
path: BUILD_DIR,
filename: '[name].[hash].js',
'publicPath': '/'
},
module : {
loaders : [
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.jsx$/, loader: 'babel-loader', exclude: /node_modules/ },
{
test: /\.scss$/,
use: extractSass.extract({
use: [{
loader: "css-loader",
options: {
minimize: true,
modules: true,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
}, {
loader: "sass-loader"
}],
// use style-loader in development
fallback: "style-loader"
})
}
]
},
plugins: [
extractSass,
HtmlWebpackPluginConfig,
new MinifyPlugin,
new CleanWebpackPlugin(pathsToClean, {verbose:true, watch:true}),
]
};
module.exports = config;