Passed
Push — v3 ( c5893f...21dc87 )
by Andrew
08:27
created

webpack.config.js (1 issue)

1
var path = require('path')
2
var webpack = require('webpack')
3
4
const ExtractTextPlugin = require('extract-text-webpack-plugin');
5
const CleanWebpackPlugin = require('clean-webpack-plugin');
6
const ManifestPlugin = require('webpack-manifest-plugin');
7
8
const assetBundleRoot = './src/assetbundles/seomatic';
9
const inProduction = process.env.NODE_ENV === 'production';
10
11
module.exports = {
12
    entry: {
13
        'vendor': ['brace', 'brace/theme/github'],
14
        'seomatic': [
15
            path.resolve(assetBundleRoot, './src/js/seomatic.js'),
16
            path.resolve(assetBundleRoot, './src/js/twig-editor.js'),
17
            path.resolve(assetBundleRoot, './src/js/javascript-editor.js'),
18
        ],
19
        'seomatic-chart': [
20
            path.resolve(assetBundleRoot, './src/js/seomatic-chart.js'),
21
        ]
22
    },
23
    output: {
24
        path: path.resolve(__dirname, assetBundleRoot + '/dist'),
25
        publicPath: assetBundleRoot,
26
        filename: path.join('./js', '[name].js')
27
    },
28
    module: {
29
        rules: [
30
            {
31
                test: /bootstrap-tokenfield[\/\\]js[\/\\]bootstrap-tokenfield.js$/,
32
                loader: "imports-loader?define=>false"
33
            },
34
            {
35
                test: /\.vue$/,
36
                loader: 'vue-loader',
37
                options: {
38
                    loaders: {}
39
                    // other vue-loader options go here
40
                }
41
            },
42
            {
43
                test: /\.js$/,
44
                loader: 'babel-loader',
45
                exclude: /node_modules/
46
            },
47
            {
48
                test: /\.s[ac]ss$/,
49
                use: ExtractTextPlugin.extract({
50
                    fallback: 'style-loader',
51
                    use: ['css-loader', 'sass-loader'],
0 ignored issues
show
Unused Code Bug introduced by
The key use is used more than once in this object expression.
Loading history...
52
                    use: [
53
                        {
54
                            loader: 'css-loader',
55
                            options: {
56
                                url: false
57
                            }
58
                        }
59
                    ]
60
                }),
61
                exclude: /node_modules/
62
            },
63
            {
64
                test: /\.css$/,
65
                use: ExtractTextPlugin.extract({
66
                    fallback: 'style-loader',
67
                    use: [
68
                        {
69
                            loader: 'css-loader',
70
                            options: {
71
                                url: false
72
                            }
73
                        }
74
                    ]
75
                })
76
            },
77
            {
78
                test: /\.(png|jpe?g|gif|svg)$/,
79
                loader: [
80
                    {
81
                        loader: 'file-loader',
82
                        options: {
83
                            name: path.join('./img', '[name].[ext]')
84
                        }
85
                    },
86
                    'img-loader'
87
                ]
88
            }
89
        ]
90
    },
91
    plugins: [
92
        new ExtractTextPlugin({
93
            filename: path.join('./css', '[name].css'),
94
            allChunks: true,
95
        }),
96
        new webpack.LoaderOptionsPlugin({
97
            minimize: inProduction
98
        }),
99
        new CleanWebpackPlugin(['dist'], {
100
            root: path.resolve(__dirname, assetBundleRoot),
101
            verbose: true,
102
            dry: false,
103
            watch: inProduction
104
        }),
105
        new ManifestPlugin(),
106
        new webpack.optimize.CommonsChunkPlugin({
107
            names: ['vendor'],
108
            minChunks: 2
109
        })
110
    ],
111
    resolve: {
112
        alias: {
113
            'billboard.css': path.resolve(__dirname,'./node_modules/billboard.js/dist/billboard.css')
114
        }
115
    },
116
    devServer: {
117
        historyApiFallback: true,
118
        noInfo: true
119
    },
120
    performance: {
121
        hints: false
122
    },
123
    devtool: '#eval-source-map'
124
}
125
126
if (inProduction) {
127
    module.exports.devtool = '#source-map'
128
    // http://vue-loader.vuejs.org/en/workflow/production.html
129
    module.exports.plugins = (module.exports.plugins || []).concat([
130
        new webpack.DefinePlugin({
131
            'process.env': {
132
                NODE_ENV: '"production"'
133
            }
134
        }),
135
        new webpack.optimize.UglifyJsPlugin({
136
            sourceMap: true,
137
            compress: {
138
                warnings: false
139
            }
140
        }),
141
    ])
142
}
143