1 | const path = require('path')
|
2 | const webpack = require('webpack')
|
3 |
|
4 | module.exports = function createWebpackConfig () {
|
5 | const SRC = path.join(__dirname, 'src/client')
|
6 | const CWD = process.cwd()
|
7 | const QUBIT_NODE_MODULES = [
|
8 | path.join(CWD, 'node_modules', '@qubit'),
|
9 | path.join(__dirname, 'node_modules', '@qubit')
|
10 | ]
|
11 | const NODE_MODULES = [
|
12 | path.join(CWD, 'node_modules'),
|
13 | path.join(__dirname, 'node_modules')
|
14 | ]
|
15 | const BUBLE_LOADER = {
|
16 | loader: '@qubit/buble-loader',
|
17 | options: {
|
18 | objectAssign: 'Object.assign',
|
19 | transforms: {
|
20 | dangerousForOf: true,
|
21 | dangerousTaggedTemplateString: true
|
22 | }
|
23 | }
|
24 | }
|
25 | return {
|
26 | entry: [
|
27 | 'webpack-hot-middleware/client?path=https://localhost:41337/__webpack_hmr&timeout=20000&reload=true&&noInfo=true&&quiet=true'
|
28 | ],
|
29 | output: {
|
30 | path: CWD,
|
31 | publicPath: 'https://localhost:41337/',
|
32 | filename: 'bundle.js'
|
33 | },
|
34 | bail: false,
|
35 | amd: { jQuery: true },
|
36 | devtool: '#source-map',
|
37 | resolve: {
|
38 | modules: [
|
39 | CWD,
|
40 | path.join(CWD, 'node_modules'),
|
41 | path.join(__dirname, 'node_modules')
|
42 | ],
|
43 | mainFields: ['browser', 'main'],
|
44 | alias: { jquery: '@qubit/jquery' }
|
45 | },
|
46 | resolveLoader: {
|
47 | modules: [
|
48 | path.join(__dirname, 'loaders'),
|
49 | path.join(__dirname, 'node_modules')
|
50 | ]
|
51 | },
|
52 | module: {
|
53 | loaders: [
|
54 |
|
55 | {
|
56 | test: /global\.js$/,
|
57 | use: ['raw-loader']
|
58 | },
|
59 |
|
60 | {
|
61 | test: /\.js$/,
|
62 | include: [SRC],
|
63 | use: ['entry', BUBLE_LOADER]
|
64 | },
|
65 |
|
66 | {
|
67 | test: /\.js$/,
|
68 | include: [CWD],
|
69 | exclude: [/global\.js/, /node_modules/],
|
70 | use: ['experience-js', BUBLE_LOADER]
|
71 | },
|
72 |
|
73 | {
|
74 | test: /\.(css|less)$/,
|
75 | use: [
|
76 | 'raw-loader',
|
77 | 'less-loader',
|
78 | {
|
79 | loader: 'experience-less',
|
80 | options: {
|
81 | variationMasterId: true,
|
82 | experienceId: true
|
83 | }
|
84 | }
|
85 | ],
|
86 | exclude: NODE_MODULES
|
87 | },
|
88 |
|
89 | {
|
90 | test: /\.json$/,
|
91 | use: ['json-loader']
|
92 | },
|
93 |
|
94 | {
|
95 | test: /\.js$/,
|
96 | include: QUBIT_NODE_MODULES,
|
97 | use: ['experience-css', BUBLE_LOADER]
|
98 | },
|
99 | {
|
100 | test: /\.(css|less)$/,
|
101 | include: QUBIT_NODE_MODULES,
|
102 | use: ['style-loader', 'raw-loader', 'less-loader']
|
103 | }
|
104 | ]
|
105 | },
|
106 | plugins: [
|
107 | new webpack.optimize.OccurrenceOrderPlugin(),
|
108 | new webpack.HotModuleReplacementPlugin(),
|
109 | new webpack.NoEmitOnErrorsPlugin()
|
110 | ]
|
111 | }
|
112 | }
|