UNPKG

3.81 kBJavaScriptView Raw
1let path = require("path"),
2 ExtractTextPlugin = require("extract-text-webpack-plugin"),
3 StyleLintPlugin = require("stylelint-webpack-plugin"),
4 WebpackShellPlugin = require("webpack-shell-plugin");
5
6const extractSass = new ExtractTextPlugin("[name]");
7
8const lintSass = new StyleLintPlugin({
9 syntax: "scss",
10 configFile: ".stylelintrc"
11});
12
13module.exports = {
14 entry: {
15 // For Bonsai compilation
16 "dist/js/bonsai.bundle.js": "./js/index.js",
17 "dist/css/bonsai.css": "./scss/global.scss",
18 // For Style Guide Production/Test builds
19 "documentation/assets/css/documentation.css": "./scss/documentation.scss",
20 "documentation/assets/js/bonsai.bundle.js": "./js/index.js",
21 "documentation/assets/js/colors.bundle.js": "./documentation/colors.js",
22 // For local development build
23 "styleguide/assets/css/documentation.css": "./scss/documentation.scss",
24 "styleguide/assets/js/bonsai.bundle.js": "./js/index.js",
25 "styleguide/assets/js/colors.bundle.js": "./documentation/colors.js",
26 },
27 devtool: process.env.NODE_ENV === "production" ? "#hidden-source-map" : "#inline-source-map",
28 module: {
29 rules: [
30 {
31 test: /\.html$/,
32 use: "raw-loader"
33 },
34 {
35 test: /\.md$/,
36 use: "raw-loader"
37 },
38 {
39 test: /\.modernizrrc(\.json)?$/,
40 use: [ "modernizr-loader", "json-loader"]
41 },
42 {
43 test: /\.s?css$/,
44 use: extractSass.extract({
45 use: [{
46 loader: "css-loader",
47 options: {
48 sourceMap: true
49 }
50 }, {
51 loader: "sass-loader",
52 options: {
53 includePaths: [
54 "scss",
55 "node_modules/"
56 ],
57 sourceMap: true,
58 outputStyle: "expanded"
59 }
60 }],
61 fallback: "style-loader"
62 })
63 },
64 {
65 test: /\.js$/,
66 exclude: /node_modules(?!\/foundation-sites)/,
67 loader: "babel-loader",
68 options: {
69 presets: ["env"]
70 }
71 },
72 {
73 test: /\.js$/,
74 exclude: /node_modules/,
75 loader: "eslint-loader"
76 },
77 {
78 test: /\.(eot|woff|woff2|ttf|svg)(\?\S*)?$/,
79 loader: "url-loader?limit=100000&name=./dist/fonts/[hash].[ext]"
80 },
81 {
82 test: /\.(png|jpe?g|gif)$/,
83 use: [{
84 loader: "file-loader",
85 options: {
86 name: "[path][name].[ext]",
87 publicPath: process.env.NODE_ENV === "production" ? "/styleguide/assets/" : "/"
88 }
89 }]
90 }
91 ]
92 },
93 resolve: {
94 alias: {
95 modernizr$: path.resolve(__dirname, ".modernizrrc"),
96 'handlebars': 'handlebars/dist/handlebars.js'
97 }
98 },
99 externals: {
100 jquery: "jQuery"
101 },
102 output: {
103 filename: "[name]"
104 },
105 plugins: [
106 extractSass,
107 lintSass,
108 new WebpackShellPlugin({
109 onBuildExit:[
110 "node generate-docs.js",
111 "echo \033[1;33mMoving images\033[0m",
112 "cp -R images documentation/assets/"
113 ]
114 })
115 ]
116};