tainacan/webpack.config.js

115 lines
2.9 KiB
JavaScript
Raw Normal View History

2018-03-27 15:33:44 +00:00
let path = require('path');
let webpack = require('webpack');
2018-03-27 18:58:52 +00:00
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
2018-01-23 14:42:01 +00:00
entry: {
dev_admin: './src/js/main.js',
user_admin: './src/admin/js/main.js'
},
output: {
path: path.resolve(__dirname, './src/assets/'),
publicPath: './src/assets/',
2018-01-23 14:42:01 +00:00
filename: '[name]-components.js'
},
module: {
rules: [
2018-03-23 13:20:37 +00:00
{
enforce: "pre",
test: /\.vue$/,
exclude: /node_modules/,
2018-03-23 16:18:13 +00:00
loader: "eslint-loader",
options: {
fix: false,
},
2018-03-23 13:20:37 +00:00
},
{
test: /\.vue$/,
2018-01-26 14:17:30 +00:00
loader: 'vue-loader',
options: {
// vue-loader options go here
}
},
{
test: /\.js$/,
2018-01-26 14:17:30 +00:00
loader: 'babel-loader',
exclude: /node_modules/
},
{
2018-01-24 18:16:35 +00:00
test: /\.(png|jpg|jpeg|gif|eot|ttf|woff|woff2|svg|svgz)(\?.+)?$/,
2018-01-26 14:17:30 +00:00
loader: 'file-loader'
2018-01-23 14:42:01 +00:00
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader'],
},
{
test: /\.scss$/,
loader: 'sass-resources-loader',
options: {
resources: path.resolve(__dirname, './src/admin/scss/_variables.scss')
}
}
]
},
2018-03-23 18:44:00 +00:00
node: {
2018-03-28 18:21:13 +00:00
fs: 'empty',
net: 'empty',
tls: 'empty'
2018-03-23 18:44:00 +00:00
},
2018-03-27 15:33:44 +00:00
performance: {
hints: false
},
};
2018-03-29 18:01:05 +00:00
// Change to false for development mode
let production = false;
if (production === true) {
console.log({'production': production});
module.exports.devtool = '';
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
2018-03-29 18:01:05 +00:00
NODE_ENV: JSON.stringify('production')
}
}),
2018-03-27 18:58:52 +00:00
new UglifyJsPlugin({
parallel: true,
2018-03-29 18:01:05 +00:00
sourceMap: false
2018-03-27 18:58:52 +00:00
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
2018-03-29 18:01:05 +00:00
module.exports.resolve = {
alias: {
'vue$': 'vue/dist/vue.min'
}
}
} else {
console.log({'production': production});
module.exports.devtool = '';
module.exports.plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development')
},
}),
];
module.exports.mode = 'development';
module.exports.resolve = {
alias: {
//'vue$': 'vue/dist/vue.esm' // uncomment this and comment the above to use vue dev tools (can cause type error)
'vue$': 'vue/dist/vue.min'
}
2018-03-27 18:58:52 +00:00
}
}