You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
3.0 KiB
103 lines
3.0 KiB
const webpack = require('webpack');
|
|
const path = require('path');
|
|
const NODE_ENV = process.env.NODE_ENV || 'development';
|
|
const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
|
|
|
module.exports = {
|
|
entry: {
|
|
app: "./src/js/app.js",
|
|
courseRedactor: "./src/js/course-redactor.js"
|
|
},
|
|
output: {
|
|
path: path.join(__dirname, "build"),
|
|
filename: NODE_ENV === 'development' ? '[name].js' : '[name].[id].[chunkhash].js',
|
|
library: '[name]',
|
|
publicPath: '/static/',
|
|
},
|
|
module: {
|
|
loaders: [
|
|
{
|
|
test: /\.js$/,
|
|
exclude: /(node_modules|bower_components)/,
|
|
use: {
|
|
loader: 'babel-loader',
|
|
options: {
|
|
presets: [
|
|
["env", {
|
|
"targets": {
|
|
"browsers": ["last 2 versions", "safari >= 7"]
|
|
}
|
|
}]
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
use: ExtractTextPlugin.extract({
|
|
fallback: 'style-loader',
|
|
use: ['css-loader']
|
|
})
|
|
},
|
|
{
|
|
test: /\.s[ac]ss$/,
|
|
use: ExtractTextPlugin.extract({
|
|
fallback: 'style-loader',
|
|
use: ['css-loader', 'sass-loader']
|
|
})
|
|
},
|
|
{
|
|
test: /\.vue$/,
|
|
loader: 'vue-loader',
|
|
exclude: [/node_modules/],
|
|
options: {
|
|
loaders: {
|
|
css: 'vue-style-loader!css-loader',
|
|
scss: 'vue-style-loader!css-loader!sass-loader',
|
|
sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
test: /\.(png|gif|jpg|woff|woff2|eot|ttf|svg)$/,
|
|
loader: 'url-loader?limit=100000'
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new webpack.DefinePlugin({
|
|
'process.env': {
|
|
'NODE_ENV': JSON.stringify(NODE_ENV)
|
|
}
|
|
}),
|
|
new webpack.ProvidePlugin({
|
|
$: "jquery",
|
|
jQuery: "jquery",
|
|
"window.jQuery": "jquery"
|
|
}),
|
|
new ExtractTextPlugin('[name].css'),
|
|
],
|
|
|
|
resolve: {
|
|
alias: {
|
|
vue: 'vue/dist/vue.js'
|
|
},
|
|
extensions: ['*', '.js', '.vue']
|
|
},
|
|
|
|
watch: NODE_ENV === 'development',
|
|
|
|
devtool: NODE_ENV === 'development' ? 'source-map' : false
|
|
};
|
|
|
|
if (NODE_ENV === 'production') {
|
|
module.exports.plugins.push(
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
compress: {
|
|
warnings: false,
|
|
drop_console: true,
|
|
unsafe: true
|
|
}
|
|
})
|
|
);
|
|
} |