const path = require('path'); const webpack = require('webpack'); const autoprefixer = require('autoprefixer'); // App files location const PATHS = { app: path.resolve(__dirname, '../src/js'), styles: path.resolve(__dirname, '../src/styles'), build: path.resolve(__dirname, '../build-dev'), resolveRoot: path.resolve(__dirname, '../src') }; const plugins = [ new webpack.EnvironmentPlugin([ "NODE_ENV","BUILD_TYPE" ]), // Shared code /*new webpack.optimize.CommonsChunkPlugin({ names: ["app", "engine"], minChunks: Infinity }),*/ // Avoid publishing files when compilation fails new webpack.NoErrorsPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('development'), __DEV__: JSON.stringify(JSON.parse(process.env.DEBUG || 'false')) }), new webpack.optimize.OccurenceOrderPlugin() /*,new webpack.optimize.DedupePlugin()*/ ]; const sassLoaders = [ 'style-loader', 'css-loader?sourceMap', 'postcss-loader', 'sass-loader?outputStyle=expanded' ]; module.exports = { env : process.env.NODE_ENV, entry: { app: path.resolve(PATHS.app, 'main.js'), engine: path.resolve(PATHS.app, 'core/engine/index.js'), engineExt: path.resolve(PATHS.app, 'core/engine/engine-ext.js') //vendor: ['react'] }, output: { path: PATHS.build, filename: 'js/[name].js', publicPath: '/' }, stats: { colors: true, reasons: true }, resolve: { // We can now require('file') instead of require('file.jsx') extensions: ['', '.js', '.jsx', '.scss'], root: [PATHS.resolveRoot], alias: { vue: 'vue/dist/vue.js'} // loads the standalone version that includes the template compiler }, module: { preLoaders: [ { test: /\.json$/, loader: 'json'}, ], loaders: [ { test: /\.vue$/, loader: 'vue-loader' }, { test: /\.(js|jsx)$/, loaders: ['babel'], include: PATHS.app }, { test: /\.scss$/, loader: sassLoaders.join('!') }, { test: /\.css$/, loader: 'style-loader!css-loader!postcss-loader' }, // Inline base64 URLs for <=8k images, direct URLs for the rest { test: /\.(png|woff|woff2|eot|ttf|jpg|jpeg|gif|svg)(\?\S*)?$/, loader: 'url-loader', options: { name: '[name].[ext]?[hash]' } } ] }, plugins: plugins, postcss: function () { return [autoprefixer({ browsers: ['last 2 versions'] })]; }, devServer: { outputPath: PATHS.build, contentBase: path.resolve(__dirname, '../src'), historyApiFallback: { disableDotRule: true, rewrites: [ { // take care of static assets from: /^\/assets\/.*$/, to: function(context) { return context.parsedUrl.pathname; } } ] }, hot: false, port: 3000 }, devtool: 'eval', vue: { less: 'css!less' } };